You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by ya...@apache.org on 2019/04/23 07:40:24 UTC

[struts] branch master updated: allow white-space around "; " character in multipart request RegEx

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

yasserzamani pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/struts.git


The following commit(s) were added to refs/heads/master by this push:
     new b7d64f3  allow white-space around ";" character in multipart request RegEx
b7d64f3 is described below

commit b7d64f3a01b0c18b2f81b46e1117c05b756d5e2b
Author: Yasser Zamani <ya...@apache.org>
AuthorDate: Tue Apr 23 12:09:58 2019 +0430

    allow white-space around ";" character in multipart request RegEx
    
    fixes WW-4958
---
 .../org/apache/struts2/dispatcher/Dispatcher.java   |  2 +-
 .../apache/struts2/dispatcher/DispatcherTest.java   | 21 +++++++++++++++++++++
 2 files changed, 22 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 92b8ac0..575de94 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
@@ -86,7 +86,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=[0-9a-zA-Z'()+_,\\-./:=?]{1,70})?(?:\\s*;\\s*charset=[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 43f0f9b..1669fc6 100644
--- a/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java
+++ b/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java
@@ -341,6 +341,27 @@ 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));
     }
 
     public void testServiceActionResumePreviousProxy() throws Exception {