Repository navigation
Accept BWS between the chunk size and the first chunk extension - #1261
Open
arturobernalg wants to merge 1 commit into
Open
arturobernalg wants to merge 1 commit into
arturobernalg wants to merge 1 commit into
Conversation
RFC 9112, section 7.1.1 defines chunk-ext as *( BWS ";" BWS chunk-ext-name [ BWS "=" BWS chunk-ext-val ] ) and RFC 9110, section 5.6.3 requires a recipient to parse and remove BWS. The chunk extension parser already accepted BWS after the first semicolon, but whitespace between the chunk size and the first semicolon was treated as an invalid hex digit and the request was rejected. Whitespace is now accepted after the chunk size only when it is followed by a chunk extension. A chunk size followed by whitespace and CRLF, or whitespace before or within the chunk size, is still rejected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RFC 9112, section 7.1.1 defines
and RFC 9110, section 5.6.3 states "A recipient MUST parse for such bad whitespace and remove it before interpreting the protocol element".
ChunkExtensionalready accepts BWS after the first semicolon (andTestChunkExtensionmodels optional whitespace before it), butChunkedInputFilterhandled the bytes between the chunk size and the first semicolon itself and treated whitespace as an invalid hex digit, so3 ;a=bwas rejected.Whitespace is now accepted after the chunk size only when it is followed by a chunk extension. A chunk size followed by whitespace and CRLF (not allowed by the grammar), whitespace before the chunk size and whitespace within the chunk size are still rejected.
Tested on a local Tomcat (chunked POST read by a servlet), compared with httpd 2.4.69 (mod_dav PUT) and Netty 4.1.130 (
HttpRequestDecoder):3 ; ext=val3\t;ext3+ CRLF3;extThe tests for the accepted chunk headers (testChunkSizeBwsBeforeExtension, testChunkSizeBwsTabBeforeExtension) fail without the change; the other new tests check that invalid chunk headers are still rejected.