in commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/MultipartInput.java [803:833]
public boolean readBoundary() throws FileUploadSizeException, MalformedStreamException {
final var marker = new byte[2];
final boolean nextChunk;
head += boundaryLength;
try {
marker[0] = readByte();
if (marker[0] == LF) {
// Work around IE5 Mac bug with input type=image.
// Because the boundary delimiter, not including the trailing
// CRLF, must not appear within any file (RFC 2046, section
// 5.1.1), we know the missing CR is due to a buggy browser
// rather than a file containing something similar to a
// boundary.
return true;
}
marker[1] = readByte();
if (arrayEquals(marker, STREAM_TERMINATOR, 2)) {
nextChunk = false;
} else if (arrayEquals(marker, FIELD_SEPARATOR, 2)) {
nextChunk = true;
} else {
throw new MalformedStreamException("Unexpected characters follow a boundary");
}
} catch (final FileUploadSizeException e) {
throw e;
} catch (final IOException e) {
throw new MalformedStreamException("Stream ended unexpectedly", e);
}
return nextChunk;
}