struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [17/50] git commit: Removes hardcoded excluded params
Date Wed, 18 Jun 2014 06:49:34 GMT
Removes hardcoded excluded params


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/cb590742
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/cb590742
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/cb590742

Branch: refs/heads/develop
Commit: cb590742892c39dc6abb84f6a85d87235d555f32
Parents: f84efa5
Author: Lukasz Lenart <lukaszlenart@apache.org>
Authored: Sun May 4 10:48:09 2014 +0200
Committer: Lukasz Lenart <lukaszlenart@apache.org>
Committed: Sun May 4 10:48:09 2014 +0200

----------------------------------------------------------------------
 .../interceptor/ParametersInterceptor.java      | 16 +++-----------
 .../interceptor/ParametersInterceptorTest.java  | 16 ++++++++++----
 .../src/test/resources/xwork-test-beans.xml     | 22 ++------------------
 3 files changed, 17 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/cb590742/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java
b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java
index cb38d57..e09ab54 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java
@@ -141,21 +141,16 @@ public class ParametersInterceptor extends MethodFilterInterceptor {
 
     private static final Logger LOG = LoggerFactory.getLogger(ParametersInterceptor.class);
 
-    public static final String ACCEPTED_PARAM_NAMES = "\\w+((\\.\\w+)|(\\[\\d+\\])|(\\(\\d+\\))|(\\['(\\w|[\\u4e00-\\u9fa5])+'\\])|(\\('(\\w|[\\u4e00-\\u9fa5])+'\\)))*";
-
     protected static final int PARAM_NAME_MAX_LENGTH = 100;
 
     private int paramNameMaxLength = PARAM_NAME_MAX_LENGTH;
+    private boolean devMode = false;
 
     protected boolean ordered = false;
+
     protected Set<Pattern> excludeParams = Collections.emptySet();
     protected Set<Pattern> acceptParams = Collections.emptySet();
 
-    private boolean devMode = false;
-
-    // Allowed names of parameters
-    private Pattern acceptedPattern = Pattern.compile(ACCEPTED_PARAM_NAMES);
-
     private ValueStackFactory valueStackFactory;
 
     @Inject
@@ -426,13 +421,8 @@ public class ParametersInterceptor extends MethodFilterInterceptor {
             }
             notifyDeveloper("Parameter [#0] didn't match acceptParams list of patterns!",
paramName);
             return false;
-        } else {
-            boolean matches = acceptedPattern.matcher(paramName).matches();
-            if (!matches) {
-                notifyDeveloper("Parameter [#0] didn't match acceptedPattern pattern!", paramName);
-            }
-            return matches;
         }
+        return true;
     }
 
     protected boolean isExcluded(String paramName) {

http://git-wip-us.apache.org/repos/asf/struts/blob/cb590742/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ParametersInterceptorTest.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ParametersInterceptorTest.java
b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ParametersInterceptorTest.java
index f0adf02..79f46e6 100644
--- a/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ParametersInterceptorTest.java
+++ b/xwork-core/src/test/java/com/opensymphony/xwork2/interceptor/ParametersInterceptorTest.java
@@ -32,11 +32,13 @@ import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
 import com.opensymphony.xwork2.mock.MockActionInvocation;
 import com.opensymphony.xwork2.ognl.OgnlValueStack;
 import com.opensymphony.xwork2.ognl.OgnlValueStackFactory;
+import com.opensymphony.xwork2.ognl.SecurityMemberAccess;
 import com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor;
 import com.opensymphony.xwork2.util.CompoundRoot;
 import com.opensymphony.xwork2.util.ValueStack;
 import com.opensymphony.xwork2.util.ValueStackFactory;
 import junit.framework.Assert;
+import ognl.OgnlContext;
 import ognl.PropertyAccessor;
 
 import java.io.File;
@@ -293,9 +295,8 @@ public class ParametersInterceptorTest extends XWorkTestCase {
 
         //then
         assertEquals("This is blah", ((SimpleAction) proxy.getAction()).getBlah());
-        Object allowMethodAccess = stack.findValue("\u0023_memberAccess['allowStaticMethodAccess']");
-        assertNotNull(allowMethodAccess);
-        assertEquals(Boolean.FALSE, allowMethodAccess);
+        boolean allowMethodAccess = ((SecurityMemberAccess) ((OgnlContext) stack.getContext()).getMemberAccess()).getAllowStaticMethodAccess();
+        assertFalse(allowMethodAccess);
     }
 
     public void testParameters() throws Exception {
@@ -323,7 +324,7 @@ public class ParametersInterceptorTest extends XWorkTestCase {
         ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.PARAM_INTERCEPTOR_ACTION_NAME,
null, extraContext);
         proxy.execute();
         Map<String, String> existingMap = ((SimpleAction) proxy.getAction()).getTheProtectedMap();
-        assertEquals(0, existingMap.size());
+        assertEquals(4, existingMap.size());
     }
 
     public void testParametersWithChineseInTheName() throws Exception {
@@ -650,6 +651,13 @@ public class ParametersInterceptorTest extends XWorkTestCase {
         final Map<String, Object> expected = new HashMap<String, Object>() {
             {
                 put("ordinary.bean", "value");
+                put("#some.internal.object", "true");
+                put("(bla)#some.internal.object", "true");
+                put("#some.internal.object(bla)#some.internal.object", "true");
+                put("#_some.internal.object", "true");
+                put("\u0023_some.internal.object", "true");
+                put("\u0023_some.internal.object,[dfd],bla(\u0023_some.internal.object)",
"true");
+                put("\\u0023_some.internal.object", "true");
             }
         };
 

http://git-wip-us.apache.org/repos/asf/struts/blob/cb590742/xwork-core/src/test/resources/xwork-test-beans.xml
----------------------------------------------------------------------
diff --git a/xwork-core/src/test/resources/xwork-test-beans.xml b/xwork-core/src/test/resources/xwork-test-beans.xml
index 7268ef7..1606f1d 100644
--- a/xwork-core/src/test/resources/xwork-test-beans.xml
+++ b/xwork-core/src/test/resources/xwork-test-beans.xml
@@ -3,25 +3,7 @@
         "http://struts.apache.org/dtds/xwork-2.0.dtd">
 
 <xwork>
-<!--
-	<bean class="com.opensymphony.xwork2.ObjectFactory" name="default" />
-	<bean type="com.opensymphony.xwork2.ActionProxyFactory" name="default" class="com.opensymphony.xwork2.DefaultActionProxyFactory"/>
-	<constant name="devMode" value="false" />
 
-	<bean type="com.opensymphony.xwork2.util.ValueStackFactory"
-    	  class="com.opensymphony.xwork2.ognl.OgnlValueStackFactory" />
-    <bean type="com.opensymphony.xwork2.util.reflection.ReflectionProvider"
-          class="com.opensymphony.xwork2.ognl.OgnlReflectionProvider" />
-    <bean type="com.opensymphony.xwork2.util.reflection.ReflectionContextFactory"
-          class="com.opensymphony.xwork2.ognl.OgnlReflectionContextFactory" />
-    <bean class="com.opensymphony.xwork2.conversion.impl.XWorkConverter" />
-    <bean type="com.opensymphony.xwork2.conversion.ObjectTypeDeterminer"
-    	  class="com.opensymphony.xwork2.conversion.impl.DefaultObjectTypeDeterminer" />
--->
-    <!--  static injections -->
-    <!--
-    <bean class="com.opensymphony.xwork2.ognl.OgnlValueStack" static="true"/>
-    <bean class="com.opensymphony.xwork2.conversion.impl.XWorkConverter" static="true"/>
-    <bean class="com.opensymphony.xwork2.util.reflection.ReflectionProviderFactory" static="true"
/>
-    -->
+    <constant name="ognlExcludedClasses" value="java.lang.Object,java.lang.Runtime,ognl.OgnlContext,ognl.MemberAccess,ognl.ClassResolver,ognl.TypeConverter,com.opensymphony.xwork2.ognl.SecurityMemberAccess"
/>
+
 </xwork>
\ No newline at end of file


Mime
View raw message