Commits

musachy  committed 18b77c2

WW-2806 Add spaces as valid characters to param names

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@1882e221344d-f017-0410-9bd5-d282ab1896d7

  • Participants
  • Parent commits 511c7b8

Comments (0)

Files changed (2)

File src/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java

     Set<Pattern> acceptParams = Collections.emptySet();
     static boolean devMode = false;
 
-    private String acceptedParamNames = "[\\p{Graph}&&[^,#:=]]*";
+    private String acceptedParamNames = "[[\\p{Graph}\\s]&&[^,#:=]]*";
     private Pattern acceptedPattern = Pattern.compile(acceptedParamNames);
 
     private ValueStackFactory valueStackFactory;

File src/test/com/opensymphony/xwork2/interceptor/ParametersInterceptorTest.java

         assertEquals("This is blah", ((SimpleAction) proxy.getAction()).getBlah());
     }
 
+     public void testParametersWithSpacesInTheName() throws Exception {
+        Map<String, Object> params = new HashMap<String, Object>();
+        params.put("theProtectedMap['p0 p1']", "test1");
+        params.put("theProtectedMap['p0p1 ']", "test2");
+        params.put("theProtectedMap[' p0p1 ']", "test3");
+        params.put("theProtectedMap[' p0 p1 ']", "test4");
+
+        HashMap<String, Object> extraContext = new HashMap<String, Object>();
+        extraContext.put(ActionContext.PARAMETERS, params);
+
+        ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.PARAM_INTERCEPTOR_ACTION_NAME, extraContext);
+        proxy.execute();
+        Map<String, String> existingMap =  ((SimpleAction) proxy.getAction()).getTheProtectedMap();
+        assertEquals(4, existingMap.size());
+        assertEquals("test1", existingMap.get("p0 p1"));
+        assertEquals("test2", existingMap.get("p0p1 "));
+        assertEquals("test3", existingMap.get(" p0p1 "));
+        assertEquals("test4", existingMap.get(" p0 p1 "));
+    }
+
     public void testExcludedTrickyParameters() throws Exception {
         Map<String, Object> params = new HashMap<String, Object>() {
             {