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
The following commit(s) were added to refs/heads/WW-5184-log by this push:
new 5338b44c2 WW-5184 Reduces code complexity when handling
excluded/accepted values patterns
5338b44c2 is described below
commit 5338b44c233dbc7a26a5b0c6b0993d770fa5340e
Author: Lukasz Lenart <[email protected]>
AuthorDate: Fri Sep 30 08:25:44 2022 +0200
WW-5184 Reduces code complexity when handling excluded/accepted values
patterns
---
.../xwork2/interceptor/ParametersInterceptor.java | 43 ++++++++++------------
1 file changed, 20 insertions(+), 23 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 73f650442..3fa04220a 100644
---
a/core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java
+++
b/core/src/main/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java
@@ -413,38 +413,35 @@ public class ParametersInterceptor extends
MethodFilterInterceptor {
}
protected boolean isParamValueExcluded(String value) {
- if (hasParamValuesToExclude()) {
- for (Pattern excludedPattern : excludedValuePatterns) {
- if (value != null) {
- if (excludedPattern.matcher(value).matches()) {
- if (devMode) {
- LOG.warn("Parameter value [{}] matches excluded
pattern [{}]! See Accepting/Excluding parameter values at\n" +
-
"https://struts.apache.org/core-developers/parameters-interceptor#excluding-parameter-values",
- value, excludedValuePatterns);
- } else {
- LOG.debug("Parameter value [{}] matches excluded
pattern [{}]", value, excludedPattern);
- }
- return true;
- }
+ if (!hasParamValuesToExclude()) {
+ LOG.debug("'excludedValuePatterns' not defined so anything is
allowed");
+ return false;
+ }
+ for (Pattern excludedValuePattern : excludedValuePatterns) {
+ if (excludedValuePattern.matcher(value).matches()) {
+ if (devMode) {
+ LOG.warn("Parameter value [{}] matches excluded pattern
[{}]! See Accepting/Excluding parameter values at\n" +
+
"https://struts.apache.org/core-developers/parameters-interceptor#excluding-parameter-values",
+ value, excludedValuePatterns);
+ } else {
+ LOG.debug("Parameter value [{}] matches excluded pattern
[{}]", value, excludedValuePattern);
}
+ 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
+ if (!hasParamValuesToAccept()) {
+ LOG.debug("'acceptedValuePatterns' not defined so anything is
allowed");
return true;
}
+ for (Pattern acceptedValuePattern : acceptedValuePatterns) {
+ if (acceptedValuePattern.matcher(value).matches()) {
+ return true;
+ }
+ }
if (devMode) {
LOG.warn("Parameter value [{}] didn't match accepted pattern [{}]!
See Accepting/Excluding parameter values at\n" +
"https://struts.apache.org/core-developers/parameters-interceptor#excluding-parameter-values",