-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EE10 multipart parsing may include '\r' at the front under certain conditions #10919
Comments
What generated the multipart content? I ask because if I am not mistaken, the first chunk declares a length of 0x90 (144) that ends at |
I was mistaken. Lost in the jungle of |
No worries, thanks for having a look. I can relate, this combination is confusing 😀 And a good question, I should have mentioned that. The HTTP Client is the java.net.http.HttpClient class, but the multipart format generator is custom code. So the chunking is done by Java HttpClient and should be fine. But to be honest: I changed the request to make it a bit smaller for the testcase, I wanted it to be as minimal as possibly and I could have broken something with that. |
…nder certain conditions. Setting MultiPart.Parser.crContent=false when the boundary is matched. This is necessary when a read chunk ends with \r\n, and then matches the boundary on the next read chunk, and avoids to emit the CR as part content. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
…nder certain conditions (#10921) Setting MultiPart.Parser.crContent=false when the boundary is matched. This is necessary when a read chunk ends with \r\n, and then matches the boundary on the next read chunk, and avoids to emit the CR as part content. Fixed case of a chunk ending with \r. Fixed case where a CR in a previous chunk is followed by a boundary at index 0 in the next chunk. The CR should not be emitted as content, and crContent reset to false. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Fixed by #10921. |
Jetty version(s)
12.0.3
Jetty Environment
ee10
Java version/vendor
OS type/version
Arch Linux
Description
Under certain conditions the multi-part form parsing will add a wrong
'\r'
character at the front of the content. The issue seems to only occur for requests in "chunked" transfer encoding and depends on the position in the multi-part data (see tests below).I am not 100% sure about the specifics of mime-multipart, so it could also be an error in the request. But the issue did not occur in previous versions of jetty (at the very least not in version 11 where this works), it also does not occur in "ee9" environment and not when sending to the real target (some old Perl-CGI).
How to reproduce?
Adding this test to MultiPartServletTest.java will fail at
assertEquals("abcde", content1)
becausecontent1
will contain"\rabcde"
instead of the expected "abcde".If you move the
file_upload
part within the multipart-section to the top, it will work and give me"abcde"
. The code for this is included in the folded section below.Additionally I created a testcase for the MultiPartServletTest.java of the ee9 module where the same request will have the expected result
"abcde"
. This is also included in the folded section below.More testcases
Testcase for
org.eclipse.jetty.ee9.servlet.MultiPartServletTest
(this will work because the bug does not occur for ee9)The text was updated successfully, but these errors were encountered: