myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jak...@apache.org
Subject svn commit: r933814 - /myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java
Date Tue, 13 Apr 2010 23:40:38 GMT
Author: jakobk
Date: Tue Apr 13 23:40:38 2010
New Revision: 933814

URL: http://svn.apache.org/viewvc?rev=933814&view=rev
Log:
MYFACES-2657 Already escaped apostrophes are double-escaped while building the ClientBehavior
JavaScript (test case)

Modified:
    myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java
  (contents, props changed)

Modified: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java?rev=933814&r1=933813&r2=933814&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java
(original)
+++ myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java
Tue Apr 13 23:40:38 2010
@@ -43,8 +43,8 @@ import org.apache.myfaces.test.mock.Mock
 import org.apache.myfaces.test.mock.MockResponseWriter;
 
 /**
- * @author Bruno Aranda (latest modification by $Author: grantsmith $)
- * @version $Revision: 472618 $ $Date: 2006-11-09 04:06:54 +0800 (Thu, 09 Nov 2006) $
+ * @author Bruno Aranda (latest modification by $Author$)
+ * @version $Revision$ $Date$
  */
 public class HtmlTextRendererTest extends AbstractJsfTestCase
 {
@@ -220,4 +220,26 @@ public class HtmlTextRendererTest extend
         }
     }
     
+    /**
+     * Tests if a JavaScript user code that already contains ' is correctly escaped.
+     * e.g. test = 'a\'b'; has to become test = \'a\\\'b\';
+     */
+    public void testClientBehaviorUserCodeJavaScriptDoubleEscaping()
+    {
+        inputText.getAttributes().put("onchange", "var test = \'a\\\'b\'; alert(test);");
+        inputText.addClientBehavior("change", new AjaxBehavior());
+        try 
+        {
+            inputText.encodeAll(facesContext);
+            String output = ((StringWriter) writer.getWriter()).getBuffer().toString();
+            // onchange="jsf.util.chain(document.getElementById('j_id0'),
event,
+            //               'var test = \'a\\\'b\';
alert(test);');"
+            assertTrue(output.contains("'var test = \\'a\\\\\\'b\\';
alert(test);'"));
+        }
+        catch (Exception e)
+        {
+            fail(e.getMessage());
+        }
+    }
+    
 }

Propchange: myfaces/core/trunk/impl/src/test/java/org/apache/myfaces/renderkit/html/HtmlTextRendererTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL



Mime
View raw message