397111 Allow multipart bodies with leading blank lines

Also trim any leading space from FIRST boundary
This commit is contained in:
Jan Bartel 2012-12-22 14:00:46 +11:00
parent c9135e34c9
commit 0420365f82
2 changed files with 3 additions and 0 deletions

View File

@ -151,6 +151,7 @@ public class MultiPartFilter implements Filter
if (line == null || line.length() == 0)
throw new IOException("Missing content for multipart request");
line = line.trim();
boolean badFormatLogged = false;
while (line != null && !line.equals(boundary))
{
@ -160,6 +161,7 @@ public class MultiPartFilter implements Filter
badFormatLogged = true;
}
line=((ReadLineInputStream)in).readLine();
line=(line==null?line:line.trim());
}
if (line == null || line.length() == 0)

View File

@ -67,6 +67,7 @@ public class MultipartFilterTest
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{
System.err.println(req.getParameter("field1"));
assertNotNull(req.getParameter("fileup"));
assertNotNull(req.getParameter("fileup"+MultiPartFilter.CONTENT_TYPE_SUFFIX));
assertEquals(req.getParameter("fileup"+MultiPartFilter.CONTENT_TYPE_SUFFIX), "application/octet-stream");