327601 Multipart Filter handles quoted tokens

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2344 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2010-10-13 01:53:32 +00:00
parent dddbe12c97
commit a6df844fa7
3 changed files with 35 additions and 17 deletions

View File

@ -8,6 +8,7 @@ jetty-7.2.0.RC1-SNAPSHOT
+ 327183 Allow better configurability of HttpClient for TLS/SSL + 327183 Allow better configurability of HttpClient for TLS/SSL
+ 327469 removed needless java6 dependencies + 327469 removed needless java6 dependencies
+ 327562 Implement all X-Forwarded headers in ProxyServlet + 327562 Implement all X-Forwarded headers in ProxyServlet
+ 327601 Multipart Filter handles quoted tokens
+ JETTY-1288 Info statement when atypical classloader set on WebAppContext + JETTY-1288 Info statement when atypical classloader set on WebAppContext
jetty-7.2.0.RC0 1 Oct 2010 jetty-7.2.0.RC0 1 Oct 2010

View File

@ -30,7 +30,6 @@ import java.util.Enumeration;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.StringTokenizer;
import javax.servlet.Filter; import javax.servlet.Filter;
import javax.servlet.FilterChain; import javax.servlet.FilterChain;
@ -45,6 +44,7 @@ import javax.servlet.http.HttpServletRequestWrapper;
import org.eclipse.jetty.http.security.B64Code; import org.eclipse.jetty.http.security.B64Code;
import org.eclipse.jetty.util.LazyList; import org.eclipse.jetty.util.LazyList;
import org.eclipse.jetty.util.MultiMap; import org.eclipse.jetty.util.MultiMap;
import org.eclipse.jetty.util.QuotedStringTokenizer;
import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.TypeUtil; import org.eclipse.jetty.util.TypeUtil;
@ -167,7 +167,7 @@ public class MultiPartFilter implements Filter
throw new IOException("Missing content-disposition"); throw new IOException("Missing content-disposition");
} }
StringTokenizer tok=new StringTokenizer(content_disposition,";"); QuotedStringTokenizer tok=new QuotedStringTokenizer(content_disposition,";");
String name=null; String name=null;
String filename=null; String filename=null;
while(tok.hasMoreTokens()) while(tok.hasMoreTokens())
@ -368,21 +368,7 @@ public class MultiPartFilter implements Filter
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
private String value(String nameEqualsValue) private String value(String nameEqualsValue)
{ {
String value=nameEqualsValue.substring(nameEqualsValue.indexOf('=')+1).trim(); return nameEqualsValue.substring(nameEqualsValue.indexOf('=')+1).trim();
int i=value.indexOf(';');
if(i>0)
value=value.substring(0,i);
if(value.startsWith("\""))
{
value=value.substring(1,value.indexOf('"',1));
}
else
{
i=value.indexOf(' ');
if(i>0)
value=value.substring(0,i);
}
return value;
} }
/* ------------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------- */

View File

@ -128,6 +128,37 @@ public class MultipartFilterTest
assertTrue(response.getContent().indexOf("brown cow")>=0); assertTrue(response.getContent().indexOf("brown cow")>=0);
} }
@Test
public void testEncodedPost() 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);
String content = "--" + boundary + "\r\n"+
"Content-Disposition: form-data; name=\"fileup\"; filename=\"Diplomsko Delo Lektorirano KONČNA.doc\"\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 multipart with parts encoded in base64 (RFC1521 section 5) * Test multipart with parts encoded in base64 (RFC1521 section 5)
*/ */