struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [43/56] [abbrv] struts git commit: Reverts acceptParamNames to previous behaviour
Date Mon, 17 Nov 2014 10:48:46 GMT
Reverts acceptParamNames to previous behaviour


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

Branch: refs/heads/master
Commit: 1aa2752dec32d76a43bd340286b7bda44d7c8c73
Parents: cc11cc2
Author: Lukasz Lenart <lukaszlenart@apache.org>
Authored: Mon Nov 10 08:43:04 2014 +0100
Committer: Lukasz Lenart <lukaszlenart@apache.org>
Committed: Mon Nov 10 08:43:04 2014 +0100

----------------------------------------------------------------------
 .../interceptor/ParametersInterceptor.java      | 10 ++------
 .../security/AcceptedPatternsChecker.java       | 16 ++++++------
 .../DefaultAcceptedPatternsChecker.java         | 26 +++++++++-----------
 .../DefaultExcludedPatternsChecker.java         | 26 +++++++++-----------
 .../security/ExcludedPatternsChecker.java       | 16 ++++++------
 .../interceptor/ParametersInterceptorTest.java  |  2 +-
 6 files changed, 43 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/1aa2752d/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 e2a1b39..4cd5a24 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
@@ -24,7 +24,6 @@ import com.opensymphony.xwork2.XWorkConstants;
 import com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler;
 import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
 import com.opensymphony.xwork2.inject.Inject;
-import com.opensymphony.xwork2.util.ArrayUtils;
 import com.opensymphony.xwork2.util.ClearableValueStack;
 import com.opensymphony.xwork2.util.LocalizedTextUtil;
 import com.opensymphony.xwork2.util.MemberAccessValueStack;
@@ -35,14 +34,9 @@ import com.opensymphony.xwork2.util.logging.LoggerFactory;
 import com.opensymphony.xwork2.util.reflection.ReflectionContextState;
 
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Comparator;
-import java.util.HashSet;
 import java.util.Map;
-import java.util.Set;
 import java.util.TreeMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 
 /**
@@ -487,7 +481,7 @@ public class ParametersInterceptor extends MethodFilterInterceptor {
      * @param commaDelim A comma-delimited list of regular expressions
      */
     public void setAcceptParamNames(String commaDelim) {
-        acceptedPatterns.addAcceptedPatterns(commaDelim);
+        acceptedPatterns.setAcceptedPatterns(commaDelim);
     }
 
     /**
@@ -497,7 +491,7 @@ public class ParametersInterceptor extends MethodFilterInterceptor {
      * @param commaDelim A comma-delimited list of regular expressions
      */
     public void setExcludeParams(String commaDelim) {
-        excludedPatterns.addExcludedPatterns(commaDelim);
+        excludedPatterns.setExcludedPatterns(commaDelim);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/struts/blob/1aa2752d/xwork-core/src/main/java/com/opensymphony/xwork2/security/AcceptedPatternsChecker.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/security/AcceptedPatternsChecker.java
b/xwork-core/src/main/java/com/opensymphony/xwork2/security/AcceptedPatternsChecker.java
index 6ea9ec9..3e48553 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/security/AcceptedPatternsChecker.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/security/AcceptedPatternsChecker.java
@@ -17,25 +17,25 @@ public interface AcceptedPatternsChecker {
     public IsAccepted isAccepted(String value);
 
     /**
-     * Allows add additional excluded patterns during runtime
+     * Sets excluded patterns during runtime
      *
      * @param commaDelimitedPatterns comma delimited string with patterns
      */
-    public void addAcceptedPatterns(String commaDelimitedPatterns);
+    public void setAcceptedPatterns(String commaDelimitedPatterns);
 
     /**
-     * Allows add additional excluded patterns during runtime
+     * Set excluded patterns during runtime
      *
-     * @param additionalPatterns array of additional excluded patterns
+     * @param patterns array of additional excluded patterns
      */
-    public void addAcceptedPatterns(String[] additionalPatterns);
+    public void setAcceptedPatterns(String[] patterns);
 
     /**
-     * Allows add additional excluded patterns during runtime
+     * Sets excluded patterns during runtime
      *
-     * @param additionalPatterns set of additional patterns
+     * @param patterns set of additional patterns
      */
-    public void addAcceptedPatterns(Set<String> additionalPatterns);
+    public void setAcceptedPatterns(Set<String> patterns);
 
     /**
      * Allow access list of all defined excluded patterns

http://git-wip-us.apache.org/repos/asf/struts/blob/1aa2752d/xwork-core/src/main/java/com/opensymphony/xwork2/security/DefaultAcceptedPatternsChecker.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/security/DefaultAcceptedPatternsChecker.java
b/xwork-core/src/main/java/com/opensymphony/xwork2/security/DefaultAcceptedPatternsChecker.java
index 970a52c..9071f67 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/security/DefaultAcceptedPatternsChecker.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/security/DefaultAcceptedPatternsChecker.java
@@ -22,16 +22,13 @@ public class DefaultAcceptedPatternsChecker implements AcceptedPatternsChecker
{
     private Set<Pattern> acceptedPatterns;
 
     public DefaultAcceptedPatternsChecker() {
-        acceptedPatterns = new HashSet<Pattern>();
-        for (String pattern : ACCEPTED_PATTERNS) {
-            acceptedPatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE));
-        }
+        setAcceptedPatterns(ACCEPTED_PATTERNS);
     }
 
     @Inject(value = XWorkConstants.OVERRIDE_ACCEPTED_PATTERNS, required = false)
     public void setOverrideAcceptedPatterns(String acceptablePatterns) {
         if (LOG.isWarnEnabled()) {
-            LOG.warn("Overriding [#0] with [#1], be aware that this can affect safety of
your application!",
+            LOG.warn("Overriding accepted patterns [#0] with [#1], be aware that this affects
all instances and safety of your application!",
                     XWorkConstants.OVERRIDE_ACCEPTED_PATTERNS, acceptablePatterns);
         }
         acceptedPatterns = new HashSet<Pattern>();
@@ -43,27 +40,28 @@ public class DefaultAcceptedPatternsChecker implements AcceptedPatternsChecker
{
     @Inject(value = XWorkConstants.ADDITIONAL_ACCEPTED_PATTERNS, required = false)
     public void setAdditionalAcceptedPatterns(String acceptablePatterns) {
         if (LOG.isDebugEnabled()) {
-            LOG.warn("Adding additional patterns [#0] to accepted patterns!", acceptablePatterns);
+            LOG.warn("Adding additional global patterns [#0] to accepted patterns!", acceptablePatterns);
         }
         for (String pattern : TextParseUtil.commaDelimitedStringToSet(acceptablePatterns))
{
             acceptedPatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE));
         }
     }
 
-    public void addAcceptedPatterns(String commaDelimitedPatterns) {
-        addAcceptedPatterns(TextParseUtil.commaDelimitedStringToSet(commaDelimitedPatterns));
+    public void setAcceptedPatterns(String commaDelimitedPatterns) {
+        setAcceptedPatterns(TextParseUtil.commaDelimitedStringToSet(commaDelimitedPatterns));
     }
 
-    public void addAcceptedPatterns(String[] additionalPatterns) {
-        addAcceptedPatterns(new HashSet<String>(Arrays.asList(additionalPatterns)));
+    public void setAcceptedPatterns(String[] additionalPatterns) {
+        setAcceptedPatterns(new HashSet<String>(Arrays.asList(additionalPatterns)));
     }
 
-    public void addAcceptedPatterns(Set<String> additionalPatterns) {
+    public void setAcceptedPatterns(Set<String> patterns) {
         if (LOG.isTraceEnabled()) {
-            LOG.trace("Adding additional excluded patterns [#0]", additionalPatterns);
+            LOG.trace("Sets accepted patterns [#0]", patterns);
         }
-        for (String pattern : additionalPatterns) {
-            acceptedPatterns.add(Pattern.compile(pattern));
+        acceptedPatterns = new HashSet<Pattern>(patterns.size());
+        for (String pattern : patterns) {
+            acceptedPatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/struts/blob/1aa2752d/xwork-core/src/main/java/com/opensymphony/xwork2/security/DefaultExcludedPatternsChecker.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/security/DefaultExcludedPatternsChecker.java
b/xwork-core/src/main/java/com/opensymphony/xwork2/security/DefaultExcludedPatternsChecker.java
index 868c388..3a7a0c1 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/security/DefaultExcludedPatternsChecker.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/security/DefaultExcludedPatternsChecker.java
@@ -31,16 +31,13 @@ public class DefaultExcludedPatternsChecker implements ExcludedPatternsChecker
{
     private Set<Pattern> excludedPatterns;
 
     public DefaultExcludedPatternsChecker() {
-        excludedPatterns = new HashSet<Pattern>();
-        for (String pattern : EXCLUDED_PATTERNS) {
-            excludedPatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE));
-        }
+        setExcludedPatterns(EXCLUDED_PATTERNS);
     }
 
     @Inject(value = XWorkConstants.OVERRIDE_EXCLUDED_PATTERNS, required = false)
     public void setOverrideExcludePatterns(String excludePatterns) {
         if (LOG.isWarnEnabled()) {
-            LOG.warn("Overriding [#0] with [#1], be aware that this can affect safety of
your application!",
+            LOG.warn("Overriding excluded patterns [#0] with [#1], be aware that this affects
all instances and safety of your application!",
                     XWorkConstants.OVERRIDE_EXCLUDED_PATTERNS, excludePatterns);
         }
         excludedPatterns = new HashSet<Pattern>();
@@ -52,27 +49,28 @@ public class DefaultExcludedPatternsChecker implements ExcludedPatternsChecker
{
     @Inject(value = XWorkConstants.ADDITIONAL_EXCLUDED_PATTERNS, required = false)
     public void setAdditionalExcludePatterns(String excludePatterns) {
         if (LOG.isDebugEnabled()) {
-            LOG.debug("Adding additional patterns [#0] to excluded patterns!", excludePatterns);
+            LOG.debug("Adding additional global patterns [#0] to excluded patterns!", excludePatterns);
         }
         for (String pattern : TextParseUtil.commaDelimitedStringToSet(excludePatterns)) {
             excludedPatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE));
         }
     }
 
-    public void addExcludedPatterns(String commaDelimitedPatterns) {
-        addExcludedPatterns(TextParseUtil.commaDelimitedStringToSet(commaDelimitedPatterns));
+    public void setExcludedPatterns(String commaDelimitedPatterns) {
+        setExcludedPatterns(TextParseUtil.commaDelimitedStringToSet(commaDelimitedPatterns));
     }
 
-    public void addExcludedPatterns(String[] additionalPatterns) {
-        addExcludedPatterns(new HashSet<String>(Arrays.asList(additionalPatterns)));
+    public void setExcludedPatterns(String[] patterns) {
+        setExcludedPatterns(new HashSet<String>(Arrays.asList(patterns)));
     }
 
-    public void addExcludedPatterns(Set<String> additionalPatterns) {
+    public void setExcludedPatterns(Set<String> patterns) {
         if (LOG.isTraceEnabled()) {
-            LOG.trace("Adding additional excluded patterns [#0]", additionalPatterns);
+            LOG.trace("Sets excluded patterns [#0]", patterns);
         }
-        for (String pattern : additionalPatterns) {
-            excludedPatterns.add(Pattern.compile(pattern));
+        excludedPatterns = new HashSet<Pattern>(patterns.size());
+        for (String pattern : patterns) {
+            excludedPatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/struts/blob/1aa2752d/xwork-core/src/main/java/com/opensymphony/xwork2/security/ExcludedPatternsChecker.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/security/ExcludedPatternsChecker.java
b/xwork-core/src/main/java/com/opensymphony/xwork2/security/ExcludedPatternsChecker.java
index 51751e9..81b9895 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/security/ExcludedPatternsChecker.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/security/ExcludedPatternsChecker.java
@@ -17,25 +17,25 @@ public interface ExcludedPatternsChecker {
     public IsExcluded isExcluded(String value);
 
     /**
-     * Allows add additional excluded patterns during runtime
+     * Sets excluded patterns during runtime
      *
      * @param commaDelimitedPatterns comma delimited string with patterns
      */
-    public void addExcludedPatterns(String commaDelimitedPatterns);
+    public void setExcludedPatterns(String commaDelimitedPatterns);
 
     /**
-     * Allows add additional excluded patterns during runtime
+     * Sets excluded patterns during runtime
      *
-     * @param additionalPatterns array of additional excluded patterns
+     * @param patterns array of additional excluded patterns
      */
-    public void addExcludedPatterns(String[] additionalPatterns);
+    public void setExcludedPatterns(String[] patterns);
 
     /**
-     * Allows add additional excluded patterns during runtime
+     * Sets excluded patterns during runtime
      *
-     * @param additionalPatterns set of additional patterns
+     * @param patterns set of additional patterns
      */
-    public void addExcludedPatterns(Set<String> additionalPatterns);
+    public void setExcludedPatterns(Set<String> patterns);
 
     /**
      * Allow access list of all defined excluded patterns

http://git-wip-us.apache.org/repos/asf/struts/blob/1aa2752d/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 d6fc7c5..f20e178 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
@@ -477,7 +477,7 @@ public class ParametersInterceptorTest extends XWorkTestCase {
         proxy.execute();
 
         SimpleAction action = (SimpleAction) proxy.getAction();
-        assertEquals("try_1", action.getName());
+        assertNull("try_1", action.getName());
         assertEquals("This is blah", (action).getBlah());
         assertEquals(123, action.getBaz());
     }


Mime
View raw message