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 2017/04/16 12:33:27 UTC
[1/2] struts git commit: Fixes wrong injection type
Repository: struts
Updated Branches:
refs/heads/master 1162ddf82 -> 13f49a097
Fixes wrong injection type
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/2fe05057
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/2fe05057
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/2fe05057
Branch: refs/heads/master
Commit: 2fe050578aac9e997480895c8caf4146d2725d04
Parents: 1162ddf
Author: Lukasz Lenart <lu...@apache.org>
Authored: Thu Apr 13 07:31:16 2017 +0200
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Thu Apr 13 07:31:16 2017 +0200
----------------------------------------------------------------------
.../java/org/apache/struts2/interceptor/TokenInterceptor.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/2fe05057/core/src/main/java/org/apache/struts2/interceptor/TokenInterceptor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/interceptor/TokenInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/TokenInterceptor.java
index 1361671..a31a8e9 100644
--- a/core/src/main/java/org/apache/struts2/interceptor/TokenInterceptor.java
+++ b/core/src/main/java/org/apache/struts2/interceptor/TokenInterceptor.java
@@ -23,6 +23,7 @@ package org.apache.struts2.interceptor;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.TextProvider;
+import com.opensymphony.xwork2.TextProviderFactory;
import com.opensymphony.xwork2.interceptor.ValidationAware;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
@@ -128,8 +129,8 @@ public class TokenInterceptor extends MethodFilterInterceptor {
private TextProvider textProvider;
@Inject
- public void setTextProvider(TextProvider textProvider) {
- this.textProvider = textProvider;
+ public void setTextProviderFactory(TextProviderFactory textProviderFactory) {
+ this.textProvider = textProviderFactory.createInstance(getClass());
}
/**
[2/2] struts git commit: WW-4785 Allows disable multipart support via
an config option
Posted by lu...@apache.org.
WW-4785 Allows disable multipart support via an config option
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/13f49a09
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/13f49a09
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/13f49a09
Branch: refs/heads/master
Commit: 13f49a09780e2bfba3af48ee736598fbf5c2b7b5
Parents: 2fe0505
Author: Lukasz Lenart <lu...@apache.org>
Authored: Sun Apr 16 14:33:15 2017 +0200
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Sun Apr 16 14:33:15 2017 +0200
----------------------------------------------------------------------
.../org/apache/struts2/StrutsConstants.java | 5 ++++
.../apache/struts2/dispatcher/Dispatcher.java | 24 +++++++++++++++++++-
.../struts2/dispatcher/DispatcherTest.java | 12 +++++++++-
3 files changed, 39 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/13f49a09/core/src/main/java/org/apache/struts2/StrutsConstants.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/StrutsConstants.java b/core/src/main/java/org/apache/struts2/StrutsConstants.java
index b41f7e6..f9d9b24 100644
--- a/core/src/main/java/org/apache/struts2/StrutsConstants.java
+++ b/core/src/main/java/org/apache/struts2/StrutsConstants.java
@@ -139,6 +139,11 @@ public final class StrutsConstants {
*/
public static final String STRUTS_MULTIPART_PARSER = "struts.multipart.parser";
+ /**
+ * A global switch to disable support for multipart requests
+ */
+ public static final String STRUTS_MULTIPART_ENABLED = "struts.multipart.enabled";
+
public static final String STRUTS_MULTIPART_VALIDATION_REGEX = "struts.multipart.validationRegex";
/** How Spring should autowire. Valid values are 'name', 'type', 'auto', and 'constructor' */
http://git-wip-us.apache.org/repos/asf/struts/blob/13f49a09/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
index ea92eaf..3645241 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
@@ -130,6 +130,11 @@ public class Dispatcher {
private String multipartHandlerName;
/**
+ * Stores the value of {@link StrutsConstants#STRUTS_MULTIPART_ENABLED}
+ */
+ private boolean multipartSupportEnabled = true;
+
+ /**
* A regular expression used to validate if request is a multipart/form-data request
*/
private Pattern multipartValidationPattern = Pattern.compile(MULTIPART_FORM_DATA_REGEX);
@@ -277,6 +282,11 @@ public class Dispatcher {
multipartHandlerName = val;
}
+ @Inject(value = StrutsConstants.STRUTS_MULTIPART_ENABLED, required = false)
+ public void setMultipartSupportEnabled(String multipartSupportEnabled) {
+ this.multipartSupportEnabled = Boolean.parseBoolean(multipartSupportEnabled);
+ }
+
@Inject(value = StrutsConstants.STRUTS_MULTIPART_VALIDATION_REGEX, required = false)
public void setMultipartValidationRegex(String multipartValidationRegex) {
this.multipartValidationPattern = Pattern.compile(multipartValidationRegex);
@@ -799,7 +809,7 @@ public class Dispatcher {
return request;
}
- if (isMultipartRequest(request)) {
+ if (isMultipartSupportEnabled(request) && isMultipartRequest(request)) {
MultiPartRequest multiPartRequest = getMultiPartRequest();
LocaleProviderFactory localeProviderFactory = getContainer().getInstance(LocaleProviderFactory.class);
@@ -818,6 +828,18 @@ public class Dispatcher {
}
/**
+ * Checks if support to parse multipart requests is enabled
+ *
+ * @param request current servlet request
+ * @return false if disabled
+ *
+ * @since 2.5.11
+ */
+ protected boolean isMultipartSupportEnabled(HttpServletRequest request) {
+ return multipartSupportEnabled;
+ }
+
+ /**
* Checks if request is a multipart request (a file upload request)
*
* @param request current servlet request
http://git-wip-us.apache.org/repos/asf/struts/blob/13f49a09/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java b/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java
index ffa43e1..8001bd2 100644
--- a/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java
+++ b/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java
@@ -257,7 +257,17 @@ public class DispatcherTest extends StrutsInternalTestCase {
mockContainer.verify();
mockConfiguration.verify();
}
-
+
+ public void testMultipartSupportEnabledByDefault() throws Exception {
+ HttpServletRequest req = new MockHttpServletRequest();
+ HttpServletResponse res = new MockHttpServletResponse();
+
+ Dispatcher du = initDispatcher(Collections.<String, String>emptyMap());
+ du.prepare(req, res);
+
+ assertTrue(du.isMultipartSupportEnabled(req));
+ }
+
class InternalConfigurationManager extends ConfigurationManager {
public boolean destroyConfiguration = false;