480764 - Error parsing empty multipart.
Fixed by checking the presence of the last boundary as the first line.
This commit is contained in:
parent
0979125295
commit
487d0f2d5c
|
@ -175,7 +175,7 @@ public class MultiPartInputStreamParser
|
|||
{
|
||||
if (name == null)
|
||||
return null;
|
||||
return (String)_headers.getValue(name.toLowerCase(Locale.ENGLISH), 0);
|
||||
return _headers.getValue(name.toLowerCase(Locale.ENGLISH), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -357,7 +357,7 @@ public class MultiPartInputStreamParser
|
|||
return Collections.emptyList();
|
||||
|
||||
Collection<List<Part>> values = _parts.values();
|
||||
List<Part> parts = new ArrayList<Part>();
|
||||
List<Part> parts = new ArrayList<>();
|
||||
for (List<Part> o: values)
|
||||
{
|
||||
List<Part> asList = LazyList.getList(o, false);
|
||||
|
@ -404,7 +404,7 @@ public class MultiPartInputStreamParser
|
|||
{
|
||||
parse();
|
||||
Collection<List<Part>> values = _parts.values();
|
||||
List<Part> parts = new ArrayList<Part>();
|
||||
List<Part> parts = new ArrayList<>();
|
||||
for (List<Part> o: values)
|
||||
{
|
||||
List<Part> asList = LazyList.getList(o, false);
|
||||
|
@ -425,7 +425,7 @@ public class MultiPartInputStreamParser
|
|||
throws IOException
|
||||
{
|
||||
parse();
|
||||
return (Part)_parts.getValue(name, 0);
|
||||
return _parts.getValue(name, 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -443,7 +443,7 @@ public class MultiPartInputStreamParser
|
|||
|
||||
//initialize
|
||||
long total = 0; //keep running total of size of bytes read from input and throw an exception if exceeds MultipartConfigElement._maxRequestSize
|
||||
_parts = new MultiMap<Part>();
|
||||
_parts = new MultiMap<>();
|
||||
|
||||
//if its not a multipart request, don't parse it
|
||||
if (_contentType == null || !_contentType.startsWith("multipart/form-data"))
|
||||
|
@ -477,7 +477,8 @@ public class MultiPartInputStreamParser
|
|||
}
|
||||
|
||||
String boundary="--"+contentTypeBoundary;
|
||||
byte[] byteBoundary=(boundary+"--").getBytes(StandardCharsets.ISO_8859_1);
|
||||
String lastBoundary=boundary+"--";
|
||||
byte[] byteBoundary=lastBoundary.getBytes(StandardCharsets.ISO_8859_1);
|
||||
|
||||
// Get first boundary
|
||||
String line = null;
|
||||
|
@ -496,7 +497,7 @@ public class MultiPartInputStreamParser
|
|||
|
||||
boolean badFormatLogged = false;
|
||||
line=line.trim();
|
||||
while (line != null && !line.equals(boundary))
|
||||
while (line != null && !line.equals(boundary) && !line.equals(lastBoundary))
|
||||
{
|
||||
if (!badFormatLogged)
|
||||
{
|
||||
|
@ -510,6 +511,10 @@ public class MultiPartInputStreamParser
|
|||
if (line == null)
|
||||
throw new IOException("Missing initial multi part boundary");
|
||||
|
||||
// Empty multipart.
|
||||
if (line.equals(lastBoundary))
|
||||
return;
|
||||
|
||||
// Read each part
|
||||
boolean lastPart=false;
|
||||
|
||||
|
@ -519,7 +524,7 @@ public class MultiPartInputStreamParser
|
|||
String contentType=null;
|
||||
String contentTransferEncoding=null;
|
||||
|
||||
MultiMap<String> headers = new MultiMap<String>();
|
||||
MultiMap<String> headers = new MultiMap<>();
|
||||
while(true)
|
||||
{
|
||||
line=((ReadLineInputStream)_in).readLine();
|
||||
|
|
Loading…
Reference in New Issue