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 2022/09/30 05:48:21 UTC

[struts] 01/01: WW-5184 Uses the same pattern with devMode logging as in other check methods

This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch WW-5184-log
in repository https://gitbox.apache.org/repos/asf/struts.git

commit 8bd91b36048eab8c13dbe3e2eb12303f9b18388e
Author: Lukasz Lenart <lu...@apache.org>
AuthorDate: Wed Sep 28 11:35:12 2022 +0200

    WW-5184 Uses the same pattern with devMode logging as in other check methods
---
 .../xwork2/interceptor/ParametersInterceptor.java  | 96 +++++++++++-----------
 1 file changed, 48 insertions(+), 48 deletions(-)

diff --git a/core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java b/core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java
index ff962c895..b1b4dcff7 100644
--- a/core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java
+++ b/core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java
@@ -281,13 +281,13 @@ public class ParametersInterceptor extends MethodFilterInterceptor {
      * @return true if parameter is accepted
      */
     protected boolean isAcceptableParameterValue(Parameter param, Object action) {
-    	ParameterValueAware parameterValueAware = (action instanceof ParameterValueAware) ? (ParameterValueAware) action : null;
-    	boolean acceptableParmValue = (parameterValueAware == null || parameterValueAware.acceptableParameterValue(param.getValue()));
-    	if(hasParamValuesToExclude() || hasParamValuesToAccept()) {
-    		// Additional validations to process
-    		acceptableParmValue &= acceptableValue(param.getName(), param.getValue());
-    	}
-    	return acceptableParmValue;
+        ParameterValueAware parameterValueAware = (action instanceof ParameterValueAware) ? (ParameterValueAware) action : null;
+        boolean acceptableParamValue = (parameterValueAware == null || parameterValueAware.acceptableParameterValue(param.getValue()));
+        if (hasParamValuesToExclude() || hasParamValuesToAccept()) {
+            // Additional validations to process
+            acceptableParamValue &= acceptableValue(param.getName(), param.getValue());
+        }
+        return acceptableParamValue;
     }
 
     /**
@@ -415,81 +415,81 @@ public class ParametersInterceptor extends MethodFilterInterceptor {
 
 
     public void setAcceptedValuePatterns(String commaDelimitedPatterns) {
-    	Set<String> patterns = TextParseUtil.commaDelimitedStringToSet(commaDelimitedPatterns);
+        Set<String> patterns = TextParseUtil.commaDelimitedStringToSet(commaDelimitedPatterns);
         if (acceptedValuePatterns == null) {
             // Limit unwanted log entries (for 1st call, acceptedValuePatterns null)
             LOG.debug("Sets accepted value patterns to [{}], note this may impact the safety of your application!", patterns);
         } else {
             LOG.warn("Replacing accepted patterns [{}] with [{}], be aware that this affects all instances and may impact the safety of your application!",
-            		acceptedValuePatterns, patterns);
+                acceptedValuePatterns, patterns);
         }
         acceptedValuePatterns = new HashSet<>(patterns.size());
         try {
             for (String pattern : patterns) {
-            	acceptedValuePatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE));
+                acceptedValuePatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE));
             }
         } finally {
-        	acceptedValuePatterns = Collections.unmodifiableSet(acceptedValuePatterns);
+            acceptedValuePatterns = Collections.unmodifiableSet(acceptedValuePatterns);
         }
     }
 
     public void setExcludeValuePatterns(String commaDelimitedPatterns) {
-    	Set<String> patterns = TextParseUtil.commaDelimitedStringToSet(commaDelimitedPatterns);
+        Set<String> patterns = TextParseUtil.commaDelimitedStringToSet(commaDelimitedPatterns);
         if (excludedValuePatterns == null) {
             // Limit unwanted log entries (for 1st call, excludedValuePatterns null)
             LOG.debug("Setting excluded value patterns to [{}]", patterns);
         } else {
             LOG.warn("Replacing accepted patterns [{}] with [{}], be aware that this affects all instances and may impact safety of your application!",
-            		excludedValuePatterns, patterns);
+                excludedValuePatterns, patterns);
         }
         excludedValuePatterns = new HashSet<>(patterns.size());
         try {
             for (String pattern : patterns) {
-            	excludedValuePatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE));
+                excludedValuePatterns.add(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE));
             }
         } finally {
-        	excludedValuePatterns = Collections.unmodifiableSet(excludedValuePatterns);
+            excludedValuePatterns = Collections.unmodifiableSet(excludedValuePatterns);
         }
     }
 
-	protected boolean isParamValueExcluded(String value) {
-		if (hasParamValuesToExclude()) {
-			for (Pattern excludedPattern : excludedValuePatterns) {
-				if (value != null) {
-					if (excludedPattern.matcher(value).matches()) {
-						LOG.warn("Parameter value [{}] matches excluded pattern [{}] and will be dropped.", value,
-								excludedPattern);
-						return true;
-					}
-				}
-			}
-		}
-		return false;
-	}
-
-	protected boolean isParamValueAccepted(String value) {
-		if (hasParamValuesToAccept()) {
-			for (Pattern excludedPattern : acceptedValuePatterns) {
-				if (value != null) {
-					if (excludedPattern.matcher(value).matches()) {
-						return true;
-					}
-				}
-			}
-		} else {
-			// acceptedValuePatterns not defined so anything is allowed
-			return true;
-		}
-		LOG.warn("Parameter value [{}] did not match any acceptedValuePattern pattern and will be dropped.", value);
-		return false;
-	}
+    protected boolean isParamValueExcluded(String value) {
+        if (hasParamValuesToExclude()) {
+            for (Pattern excludedPattern : excludedValuePatterns) {
+                if (value != null) {
+                    if (excludedPattern.matcher(value).matches()) {
+                        LOG.warn("Parameter value [{}] matches excluded pattern [{}] and will be dropped.", value,
+                            excludedPattern);
+                        return true;
+                    }
+                }
+            }
+        }
+        return false;
+    }
+
+    protected boolean isParamValueAccepted(String value) {
+        if (hasParamValuesToAccept()) {
+            for (Pattern excludedPattern : acceptedValuePatterns) {
+                if (value != null) {
+                    if (excludedPattern.matcher(value).matches()) {
+                        return true;
+                    }
+                }
+            }
+        } else {
+            // acceptedValuePatterns not defined so anything is allowed
+            return true;
+        }
+        LOG.warn("Parameter value [{}] did not match any acceptedValuePattern pattern and will be dropped.", value);
+        return false;
+    }
 
     private boolean hasParamValuesToExclude() {
-    	return excludedValuePatterns != null && excludedValuePatterns.size() > 0;
+        return excludedValuePatterns != null && excludedValuePatterns.size() > 0;
     }
 
     private boolean hasParamValuesToAccept() {
-    	return acceptedValuePatterns != null && acceptedValuePatterns.size() > 0;
+        return acceptedValuePatterns != null && acceptedValuePatterns.size() > 0;
     }
 
     /**