Repository navigation
Do not add leading whitespace when an obs-fold precedes the field value - #1262
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 5.2 requires a server to replace each received obs-fold with one or more SP octets before interpreting the field value, and RFC 9110, section 5.5 states that a field value does not include leading or trailing whitespace and that a parser MUST exclude it. The SP that replaces an obs-fold was also inserted when the fold came before any field value, e.g. "X-A:" CRLF " one", so the value was parsed as " one". The SP is now only inserted when the field value already has content before the fold.
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 5.2 requires a server that receives an obs-fold to either reject the message or "replace each received obs-fold with one or more SP octets prior to interpreting the field value". RFC 9110, section 5.5: "A field value does not include leading or trailing whitespace. When a specific version of HTTP allows such whitespace to appear in a message, a field parsing implementation MUST exclude such whitespace prior to evaluating the field value."
HttpHeaderParserinserts the SP that replaces an obs-fold even when the fold comes before any field value, soX-A:CRLFoneis parsed asone. The SP is now only inserted when the field value already has content before the fold.Tested on a local Tomcat (header value echoed by a JSP), compared with httpd 2.4.69 (mod_proxy, value forwarded to the backend) and Netty 4.1.130 (
HttpRequestDecoder):X-A:CRLFoneoneoneoneX-A: oneCRLFtwoone twoone twoone twoone twotestObsFoldBeforeValue and testObsFoldBeforeValueWithSpace in TestHttp11InputBuffer fail without the change; testObsFoldOnlyWhitespace checks that a fold with no field value still gives an empty value.