struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [struts] branch struts-2-5-x updated: fix multipart request RegEx
Date Tue, 23 Apr 2019 06:25:44 GMT
This is an automated email from the ASF dual-hosted git repository.

lukaszlenart 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 f94b681  fix multipart request RegEx
     new b23bfd4  Merge pull request #350 from yasserzamani/WW-4958
f94b681 is described below

commit f94b6810502ccad743c4a915a3fcde25b5ff1e3c
Author: Yasser Zamani <yasserzamani@apache.org>
AuthorDate: Tue Apr 23 09:32:43 2019 +0430

    fix multipart request RegEx
    
    Note: Unlike some similar constructs in other header fields, media
    type parameters do not allow whitespace (even "bad" whitespace)
    around the "=" character.
    
    Reference: https://tools.ietf.org/html/rfc7231#section-3.1.1.1
    See also: WW-4958
---
 .../java/org/apache/struts2/dispatcher/Dispatcher.java    |  2 +-
 .../org/apache/struts2/dispatcher/DispatcherTest.java     | 15 ---------------
 2 files changed, 1 insertion(+), 16 deletions(-)

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 87dc908..75ed51e 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(?:\\s*;\\s*boundary\\s?=[0-9a-zA-Z'()+_,\\-./:=?]{1,70})?(?:\\s*;\\s*charset\\s?=\\s?[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 5b0989a..7c11874 100644
--- a/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java
+++ b/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java
@@ -323,18 +323,6 @@ 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));
 
@@ -350,9 +338,6 @@ 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));
     }


Mime
View raw message