Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Bartel2013-05-20 01:45:53 -0400
committerJan Bartel2013-05-20 01:45:53 -0400
commit13c56e81f5ae7f4d0989945a4594cf88fd96e9e1 (patch)
tree5f72ba9b00dd80dfc88096766331d20f3b64e307 /jetty-servlets/src
parent51c1017b3dc60fa2a2242d73753734b9a0c2cc31 (diff)
downloadorg.eclipse.jetty.project-13c56e81f5ae7f4d0989945a4594cf88fd96e9e1.tar.gz
org.eclipse.jetty.project-13c56e81f5ae7f4d0989945a4594cf88fd96e9e1.tar.xz
org.eclipse.jetty.project-13c56e81f5ae7f4d0989945a4594cf88fd96e9e1.zip
408446 Multipart parsing issue with boundry and charset in ContentType header
Diffstat (limited to 'jetty-servlets/src')
-rw-r--r--jetty-servlets/src/main/java/org/eclipse/jetty/servlets/MultiPartFilter.java9
-rw-r--r--jetty-servlets/src/test/java/org/eclipse/jetty/servlets/MultipartFilterTest.java33
2 files changed, 39 insertions, 3 deletions
diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/MultiPartFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/MultiPartFilter.java
index fea6d37049..c872e936fa 100644
--- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/MultiPartFilter.java
+++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/MultiPartFilter.java
@@ -125,8 +125,13 @@ public class MultiPartFilter implements Filter
// TODO - handle encodings
String contentTypeBoundary = "";
- if (content_type.indexOf("boundary=") >= 0)
- contentTypeBoundary = QuotedStringTokenizer.unquote(value(content_type.substring(content_type.indexOf("boundary="))).trim());
+ int bstart = content_type.indexOf("boundary=");
+ if (bstart >= 0)
+ {
+ int bend = content_type.indexOf(";", bstart);
+ bend = (bend < 0? content_type.length(): bend);
+ contentTypeBoundary = QuotedStringTokenizer.unquote(value(content_type.substring(bstart,bend)).trim());
+ }
String boundary="--"+contentTypeBoundary;
diff --git a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/MultipartFilterTest.java b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/MultipartFilterTest.java
index d41228a150..5f12d70442 100644
--- a/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/MultipartFilterTest.java
+++ b/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/MultipartFilterTest.java
@@ -164,7 +164,38 @@ public class MultipartFilterTest
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
assertTrue(response.getContent().indexOf("brown cow")>=0);
}
-
+
+
+ @Test
+ public void testContentTypeWithCharset() throws Exception
+ {
+ // generated and parsed test
+ HttpTester request = new HttpTester();
+ HttpTester response = new HttpTester();
+
+ // test GET
+ request.setMethod("POST");
+ request.setVersion("HTTP/1.0");
+ request.setHeader("Host","tester");
+ request.setURI("/context/dump");
+
+ String boundary="XyXyXy";
+ request.setHeader("Content-Type","multipart/form-data; boundary=\""+boundary+"\"; charset=ISO-8859-1");
+
+
+ String content = "--" + boundary + "\r\n"+
+ "Content-Disposition: form-data; name=\"fileup\"; filename=\"test.upload\"\r\n"+
+ "Content-Type: application/octet-stream\r\n\r\n"+
+ "How now brown cow."+
+ "\r\n--" + boundary + "--\r\n\r\n";
+
+ request.setContent(content);
+
+ response.parse(tester.getResponses(request.generate()));
+ assertTrue(response.getMethod()==null);
+ assertEquals(HttpServletResponse.SC_OK,response.getStatus());
+ assertTrue(response.getContent().indexOf("brown cow")>=0);
+ }
@Test
public void testEncodedPost() throws Exception

Back to the top