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

yasserzamani pushed a commit to branch struts-2-5-x
in repository https://gitbox.apache.org/repos/asf/struts.git


The following commit(s) were added to refs/heads/struts-2-5-x by this push:
     new f45d275  WW-4958 Uses less restrictive Regex to check if it's a 
multipart request
     new f5a7776  Merge pull request #344 from lukaszlenart/WW-4958
f45d275 is described below

commit f45d2752bb089ade2e41320b81283cbc8aa78259
Author: Lukasz Lenart <lukaszlen...@apache.org>
AuthorDate: Sat Mar 30 09:17:01 2019 +0100

    WW-4958 Uses less restrictive Regex to check if it's a multipart request
---
 .../org/apache/struts2/dispatcher/Dispatcher.java  |  2 +-
 .../apache/struts2/dispatcher/DispatcherTest.java  | 36 ++++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)

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 dcc5fe7..87dc908 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
@@ -85,7 +85,7 @@ public class Dispatcher {
      */
     public static final String REQUEST_POST_METHOD = "POST";
 
-    public static final String MULTIPART_FORM_DATA_REGEX = 
"^multipart/form-data(; 
boundary=[0-9a-zA-Z'()+_,\\-./:=?]{1,70})?(;charset=[a-zA-Z\\-0-9]{3,14})?";
+    public static final String MULTIPART_FORM_DATA_REGEX = 
"^multipart/form-data(?:\\s*;\\s*boundary\\s?=[0-9a-zA-Z'()+_,\\-./:=?]{1,70})?(?:\\s*;\\s*charset\\s?=\\s?[a-zA-Z\\-0-9]{3,14})?";
 
     /**
      * Provide a thread local instance.
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 7e25fb1..5b0989a 100644
--- a/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java
+++ b/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java
@@ -319,6 +319,42 @@ public class DispatcherTest extends StrutsInternalTestCase 
{
 
         req.setContentType("multipart/form-data; 
boundary=---------------------------207103069210263;charset=UTF-16LE");
         assertTrue(du.isMultipartRequest(req));
+
+        
req.setContentType("multipart/form-data;boundary=---------------------------207103069210263;charset=UTF-16LE");
+        assertTrue(du.isMultipartRequest(req));
+
+        
req.setContentType("multipart/form-data;boundary=---------------------------207103069210263
 ; charset = UTF-16LE");
+        assertTrue(du.isMultipartRequest(req));
+
+        
req.setContentType("multipart/form-data;boundary=---------------------------207103069210263;charset
 = UTF-16LE");
+        assertTrue(du.isMultipartRequest(req));
+
+        
req.setContentType("multipart/form-data;boundary=---------------------------207103069210263;charset=
 UTF-16LE");
+        assertTrue(du.isMultipartRequest(req));
+
+        
req.setContentType("multipart/form-data;boundary=---------------------------207103069210263;charset
 =UTF-16LE");
+        assertTrue(du.isMultipartRequest(req));
+
+        
req.setContentType("multipart/form-data;boundary=---------------------------207103069210263;
 charset=UTF-16LE");
+        assertTrue(du.isMultipartRequest(req));
+
+        
req.setContentType("multipart/form-data;boundary=---------------------------207103069210263
 ;charset=UTF-16LE");
+        assertTrue(du.isMultipartRequest(req));
+
+        
req.setContentType("multipart/form-data;boundary=---------------------------207103069210263
 ; charset=UTF-16LE");
+        assertTrue(du.isMultipartRequest(req));
+
+        req.setContentType("multipart/form-data 
;boundary=---------------------------207103069210263;charset=UTF-16LE");
+        assertTrue(du.isMultipartRequest(req));
+
+        req.setContentType("multipart/form-data ; 
boundary=---------------------------207103069210263;charset=UTF-16LE");
+        assertTrue(du.isMultipartRequest(req));
+
+        req.setContentType("multipart/form-data;boundary 
=---------------------------207103069210263;charset=UTF-16LE");
+        assertTrue(du.isMultipartRequest(req));
+
+        req.setContentType("Multipart/Form-Data ; 
boundary=---------------------------207103069210263;charset=UTF-16LE");
+        assertTrue(du.isMultipartRequest(req));
     }
 
     class InternalConfigurationManager extends ConfigurationManager {

Reply via email to