wicket-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jcompag...@apache.org
Subject svn commit: r782001 - in /wicket/trunk/wicket/src: main/java/org/apache/wicket/ajax/ main/java/org/apache/wicket/ajax/form/ test/java/org/apache/wicket/ajax/form/
Date Fri, 05 Jun 2009 12:46:36 GMT
Author: jcompagner
Date: Fri Jun  5 12:46:36 2009
New Revision: 782001

URL: http://svn.apache.org/viewvc?rev=782001&view=rev
Log:
& instead of & in javascript
Issue: WICKET-2033

Added:
    wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTestPage_expected.html
Modified:
    wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java
    wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTest.java

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java?rev=782001&r1=782000&r2=782001&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java Fri Jun
 5 12:46:36 2009
@@ -108,9 +108,20 @@
 		Component myComponent = getComponent();
 		if (myComponent.isEnabledInHierarchy())
 		{
-			tag.put(event, getEventHandler());
+			tag.put(event, escapeAttribute(getEventHandler()));
 		}
 	}
+	
+	private CharSequence escapeAttribute(final CharSequence attr)
+	{
+		if(null == attr)
+		{
+			return null;
+		}
+		CharSequence escaped = Strings.escapeMarkup(attr.toString());
+		// No need to escape the apostrophe; it just clutters the markup
+		return Strings.replaceAll(escaped, "'", "'");
+	}
 
 	/**
 	 * 

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java?rev=782001&r1=782000&r2=782001&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java
(original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.java
Fri Jun  5 12:46:36 2009
@@ -176,6 +176,6 @@
 	@Override
 	protected CharSequence getPreconditionScript()
 	{
-		return "return Wicket.$$(this)&&Wicket.$$('" + getForm().getMarkupId()
+ "')";
+		return "return Wicket.$$(this)&&Wicket.$$('" + getForm().getMarkupId() + "')";
 	}
 }

Modified: wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTest.java?rev=782001&r1=782000&r2=782001&view=diff
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTest.java
(original)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTest.java
Fri Jun  5 12:46:36 2009
@@ -70,4 +70,15 @@
 			.getDefaultModelObject());
 	}
 
+	/**
+	 * Test that onclick handler is generated with the proper XHTML entities
+	 * for special characters, notably ampersand. See WICKET-2033.
+	 */
+	public void testEventJavaScriptEscaped() throws Exception
+	{
+		tester.startPage(AjaxFormSubmitTestPage.class);
+		tester.assertResultPage(AjaxFormSubmitTestPage.class,
+			"AjaxFormSubmitTestPage_expected.html");
+	}
+
 }

Added: wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTestPage_expected.html
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTestPage_expected.html?rev=782001&view=auto
==============================================================================
--- wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTestPage_expected.html
(added)
+++ wicket/trunk/wicket/src/test/java/org/apache/wicket/ajax/form/AjaxFormSubmitTestPage_expected.html
Fri Jun  5 12:46:36 2009
@@ -0,0 +1,16 @@
+<html>
+	<head><script type="text/javascript" src="resources/org.apache.wicket.markup.html.WicketEventReference/wicket-event.js"></script>
+<script type="text/javascript" src="resources/org.apache.wicket.ajax.WicketAjaxReference/wicket-ajax.js"></script>
+<script type="text/javascript" src="resources/org.apache.wicket.ajax.AbstractDefaultAjaxBehavior/wicket-ajax-debug.js"></script>
+<script type="text/javascript" id="wicket-ajax-debug-enable"><!--/*--><![CDATA[/*><!--*/
+wicketAjaxDebugEnable=true;
+/*-->]]>*/</script>
+
+</head><body>
+		<form wicket:id="form" id="form1" method="post" action="?wicket:interface=:0:form::IFormSubmitListener::"><div
style="display:none"><input type="hidden" name="form1_hf_0" id="form1_hf_0" /></div>
+			<input type="text" wicket:id="txt1" value="foo" name="txt1"/>
+			<input type="text" wicket:id="txt2" value="bar" name="txt2"/>
+			<input type="submit" value="Submit" wicket:id="submit" name=":submit" id="submit2"
onclick="var wcall=wicketSubmitFormById('form1', '?wicket:interface=:0:form:submit::IActivePageBehaviorListener:0:&amp;wicket:ignoreIfNotActive=true',
':submit' ,null,null, function() {return Wicket.$$(this)&amp;&amp;Wicket.$$('form1')}.bind(this));;;
return false;"/>
+		</form>	
+	</body>
+</html>
\ No newline at end of file



Mime
View raw message