Skip to content

Commit

Permalink
Merge pull request apache#176 from lukaszlenart/multipart-regex
Browse files Browse the repository at this point in the history
WW-4862: Multipart regex
  • Loading branch information
lukaszlenart authored Oct 24, 2017
2 parents 94315da + 4ad5ff8 commit e9fe386
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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})?";
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})?";

/**
* Provide a thread local instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,36 @@ public void testMultipartSupportEnabledByDefault() throws Exception {
assertTrue(du.isMultipartSupportEnabled(req));
}

public void testIsMultipartRequest() throws Exception {
MockHttpServletRequest req = new MockHttpServletRequest();
HttpServletResponse res = new MockHttpServletResponse();

req.setMethod("POST");
Dispatcher du = initDispatcher(Collections.<String, String>emptyMap());
du.prepare(req, res);

req.setContentType("multipart/form-data");
assertTrue(du.isMultipartRequest(req));

req.setContentType("multipart/form-data; boundary=---------------------------207103069210263");
assertTrue(du.isMultipartRequest(req));

req.setContentType("multipart/form-data; boundary=---------------------------207103069210263;charset=UTF-8");
assertTrue(du.isMultipartRequest(req));

req.setContentType("multipart/form-data; boundary=---------------------------207103069210263;charset=ISO-8859-1");
assertTrue(du.isMultipartRequest(req));

req.setContentType("multipart/form-data; boundary=---------------------------207103069210263;charset=Windows-1250");
assertTrue(du.isMultipartRequest(req));

req.setContentType("multipart/form-data; boundary=---------------------------207103069210263;charset=US-ASCII");
assertTrue(du.isMultipartRequest(req));

req.setContentType("multipart/form-data; boundary=---------------------------207103069210263;charset=UTF-16LE");
assertTrue(du.isMultipartRequest(req));
}

class InternalConfigurationManager extends ConfigurationManager {
public boolean destroyConfiguration = false;

Expand Down

0 comments on commit e9fe386

Please sign in to comment.