You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by GitBox <gi...@apache.org> on 2021/07/24 12:35:07 UTC

[GitHub] [struts] lukaszlenart commented on a change in pull request #483: fix double evaluations...

lukaszlenart commented on a change in pull request #483:
URL: https://github.com/apache/struts/pull/483#discussion_r675993450



##########
File path: core/src/main/java/com/opensymphony/xwork2/security/NotExcludedAcceptedPatternsChecker.java
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.opensymphony.xwork2.security;
+
+/**
+ * Used across different places to check if given string is not excluded and is accepted
+ * @see <a href="https://securitylab.github.com/research/apache-struts-double-evaluation/">here</a>
+ * @since 2.5.27

Review comment:
       As I already pointed out, I wouldn't introduce this change in 2.5.27

##########
File path: core/src/main/java/org/apache/struts2/components/UIBean.java
##########
@@ -796,28 +792,31 @@ public void evaluateParams() {
 
 
         // see if the value was specified as a parameter already
+        final String NAME_VALUE = "nameValue";

Review comment:
       Shouldn't this be class level constant with protected scope?

##########
File path: core/src/main/java/org/apache/struts2/components/UIBean.java
##########
@@ -589,73 +586,72 @@ protected void mergeTemplate(Writer writer, Template template) throws Exception
     }
 
     public String getTemplateDir() {
-        String templateDir = null;
+        String result = null;
 
         if (this.templateDir != null) {
-            templateDir = findString(this.templateDir);
+            result = findString(this.templateDir);
         }
 
         // If templateDir is not explicitly given,
         // try to find attribute which states the dir set to use
-        if (StringUtils.isBlank(templateDir)) {
-            templateDir = stack.findString("#attr.templateDir");
+        if (StringUtils.isBlank(result)) {
+            result = stack.findString("#attr.templateDir");
         }
 
         // Default template set
-        if (StringUtils.isBlank(templateDir)) {
-            templateDir = defaultTemplateDir;
+        if (StringUtils.isBlank(result)) {
+            result = defaultTemplateDir;
         }
 
         // Defaults to 'template'
-        if (StringUtils.isBlank(templateDir)) {
-            templateDir = "template";
+        if (StringUtils.isBlank(result)) {
+            result = "template";
         }
 
-        return templateDir;
+        return result;
     }
 
     public String getTheme() {
-        String theme = null;
+        String result = null;

Review comment:
       Why did you rename this local variable?

##########
File path: core/src/main/java/com/opensymphony/xwork2/config/providers/StrutsDefaultConfigurationProvider.java
##########
@@ -212,6 +214,8 @@ public void register(ContainerBuilder builder, LocatableProperties props)
 
                 .factory(ExcludedPatternsChecker.class, DefaultExcludedPatternsChecker.class, Scope.PROTOTYPE)
                 .factory(AcceptedPatternsChecker.class, DefaultAcceptedPatternsChecker.class, Scope.PROTOTYPE)
+                .factory(NotExcludedAcceptedPatternsChecker.class, DefaultNotExcludedAcceptedPatternsChecker.class
+                        , Scope.SINGLETON)

Review comment:
       Strange formatting

##########
File path: core/src/main/java/org/apache/struts2/config/StrutsBeanSelectionProvider.java
##########
@@ -418,6 +419,8 @@ public void register(ContainerBuilder builder, LocatableProperties props) {
         /** Checker is used mostly in interceptors, so there be one instance of checker per interceptor with Scope.PROTOTYPE **/
         alias(ExcludedPatternsChecker.class, StrutsConstants.STRUTS_EXCLUDED_PATTERNS_CHECKER, builder, props, Scope.PROTOTYPE);
         alias(AcceptedPatternsChecker.class, StrutsConstants.STRUTS_ACCEPTED_PATTERNS_CHECKER, builder, props, Scope.PROTOTYPE);
+        alias(NotExcludedAcceptedPatternsChecker.class, StrutsConstants.STRUTS_NOT_EXCLUDED_ACCEPTED_PATTERNS_CHECKER
+                , builder, props, Scope.SINGLETON);

Review comment:
       Strange formatting

##########
File path: core/src/main/java/org/apache/struts2/components/UIBean.java
##########
@@ -589,73 +586,72 @@ protected void mergeTemplate(Writer writer, Template template) throws Exception
     }
 
     public String getTemplateDir() {
-        String templateDir = null;
+        String result = null;

Review comment:
       Why did you rename this local variable?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@struts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org