Skip to content

Do not add leading whitespace when an obs-fold precedes the field value - #1262

Open
arturobernalg wants to merge 1 commit into
apache:mainfrom
arturobernalg:obs-fold-leading-whitespace
Open

arturobernalg wants to merge 1 commit into
apache:mainfrom
arturobernalg:obs-fold-leading-whitespace

Conversation

@arturobernalg

@arturobernalg arturobernalg commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

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."

HttpHeaderParser inserts the SP that replaces an obs-fold even when the fold comes before any field value, so X-A: CRLF one is parsed as one. 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):

request header before after httpd Netty
X-A: CRLF one one one one rejected
X-A: one CRLF two one two one two one two one two

testObsFoldBeforeValue and testObsFoldBeforeValueWithSpace in TestHttp11InputBuffer fail without the change; testObsFoldOnlyWhitespace checks that a fold with no field value still gives an empty value.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant