You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2014/01/02 22:27:30 UTC

svn commit: r1554923 - in /struts/struts2/trunk: plugins/json/src/main/java/org/apache/struts2/json/JSONValidationInterceptor.java plugins/json/src/test/java/org/apache/struts2/json/JSONValidationInterceptorTest.java pom.xml

Author: lukaszlenart
Date: Thu Jan  2 21:27:30 2014
New Revision: 1554923

URL: http://svn.apache.org/r1554923
Log:
WW-4041 Uses the latest Commons Lang3 3.2 version and escapeJson method to solve problem with escaping single quote

Modified:
    struts/struts2/trunk/plugins/json/src/main/java/org/apache/struts2/json/JSONValidationInterceptor.java
    struts/struts2/trunk/plugins/json/src/test/java/org/apache/struts2/json/JSONValidationInterceptorTest.java
    struts/struts2/trunk/pom.xml

Modified: struts/struts2/trunk/plugins/json/src/main/java/org/apache/struts2/json/JSONValidationInterceptor.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/json/src/main/java/org/apache/struts2/json/JSONValidationInterceptor.java?rev=1554923&r1=1554922&r2=1554923&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/json/src/main/java/org/apache/struts2/json/JSONValidationInterceptor.java (original)
+++ struts/struts2/trunk/plugins/json/src/main/java/org/apache/struts2/json/JSONValidationInterceptor.java Thu Jan  2 21:27:30 2014
@@ -210,7 +210,7 @@ public class JSONValidationInterceptor e
         sb.append("[");
         for (String value : values) {
             sb.append("\"");
-            sb.append(StringEscapeUtils.escapeEcmaScript(value));
+            sb.append(StringEscapeUtils.escapeJson(value));
             sb.append("\",");
         }
         if (values.size() > 0)

Modified: struts/struts2/trunk/plugins/json/src/test/java/org/apache/struts2/json/JSONValidationInterceptorTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/json/src/test/java/org/apache/struts2/json/JSONValidationInterceptorTest.java?rev=1554923&r1=1554922&r2=1554923&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/json/src/test/java/org/apache/struts2/json/JSONValidationInterceptorTest.java (original)
+++ struts/struts2/trunk/plugins/json/src/test/java/org/apache/struts2/json/JSONValidationInterceptorTest.java Thu Jan  2 21:27:30 2014
@@ -30,6 +30,7 @@ import com.opensymphony.xwork2.mock.Mock
 import com.opensymphony.xwork2.validator.annotations.EmailValidator;
 import com.opensymphony.xwork2.validator.annotations.IntRangeFieldValidator;
 import com.opensymphony.xwork2.validator.annotations.StringLengthFieldValidator;
+import com.opensymphony.xwork2.validator.annotations.RequiredStringValidator;
 import org.apache.struts2.StrutsStatics;
 import org.apache.struts2.StrutsTestCase;
 import org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor;
@@ -74,7 +75,8 @@ public class JSONValidationInterceptorTe
                 .contains("\"errors\":[\"Generalerror\"]")
                 .contains("\"fieldErrors\":{")
                 .contains("\"value\":[\"Minvalueis-1\"]")
-                .contains("\"text\":[\"Tooshort\",\"Thisisnoemail\"]");
+                .contains("\"text\":[\"Tooshort\",\"Thisisnoemail\"]")
+                .contains("\"password\":[\"Passwordisn'tcorrect\"]");
 
         //execution
         assertFalse(action.isExecuted());
@@ -88,6 +90,7 @@ public class JSONValidationInterceptorTe
         JSONValidationInterceptor interceptor = new JSONValidationInterceptor();
 
         action.setText("abcd@ggg.com");
+        action.setPassword("apassword");
         action.setValue(10);
         
         Map parameters = new HashMap();
@@ -107,6 +110,7 @@ public class JSONValidationInterceptorTe
         JSONValidationInterceptor interceptor = new JSONValidationInterceptor();
 
         action.setText("abcd@ggg.com");
+        action.setPassword("apassword");
         action.setValue(10);
 
         //just validate
@@ -163,7 +167,8 @@ public class JSONValidationInterceptorTe
         private String text = "x";
         private int value = -10;
         private boolean executed = false;
-        
+        private String password;
+
         public String execute() {
             executed = true;
             return Action.SUCCESS;
@@ -184,6 +189,15 @@ public class JSONValidationInterceptorTe
             this.text = text;
         }
 
+        @RequiredStringValidator(message = "Password isn't correct")
+        public void setPassword(String password) {
+            this.password = password;
+        }
+
+        public String getPassword() {
+            return password;
+        }
+
         public int getValue() {
             return value;
         }

Modified: struts/struts2/trunk/pom.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/pom.xml?rev=1554923&r1=1554922&r2=1554923&view=diff
==============================================================================
--- struts/struts2/trunk/pom.xml (original)
+++ struts/struts2/trunk/pom.xml Thu Jan  2 21:27:30 2014
@@ -678,7 +678,7 @@
             <dependency>
                 <groupId>org.apache.commons</groupId>
                 <artifactId>commons-lang3</artifactId>
-                <version>3.1</version>
+                <version>3.2</version>
             </dependency>
             <dependency>
                 <groupId>commons-digester</groupId>