Skip to content

httputil: Improve handling of trailing whitespace in headers#3477

Merged
bdarnell merged 1 commit intotornadoweb:masterfrom
bdarnell:header-trailing-whitespace
Apr 24, 2025
Merged

httputil: Improve handling of trailing whitespace in headers#3477
bdarnell merged 1 commit intotornadoweb:masterfrom
bdarnell:header-trailing-whitespace

Conversation

@bdarnell
Copy link
Member

@bdarnell bdarnell commented Apr 2, 2025

HTTPHeaders had undocumented assumptions about trailing whitespace, leading to an unintentional regression in Tornado 6.4.1 in which passing the arguments of an AsyncHTTPClient header_callback to HTTPHeaders.parse_line would result in errors.

This commit moves newline parsing from parse to parse_line. It also strips trailing whitespace from continuation lines (trailing whitespace is not allowed in HTTP headers, but we didn't reject it in continuation lines).

This commit also deprecates continuation lines and the legacy handling of LF without CR.

Fixes #3321

HTTPHeaders had undocumented assumptions about trailing whitespace,
leading to an unintentional regression in Tornado 6.4.1 in which
passing the arguments of an AsyncHTTPClient header_callback to
HTTPHeaders.parse_line would result in errors.

This commit moves newline parsing from parse to parse_line.
It also strips trailing whitespace from continuation lines (trailing
whitespace is not allowed in HTTP headers, but we didn't reject it
in continuation lines).

This commit also deprecates continuation lines and the legacy
handling of LF without CR.

Fixes tornadoweb#3321
@bdarnell bdarnell merged commit 9dea6dc into tornadoweb:master Apr 24, 2025
15 checks passed
@bdarnell bdarnell deleted the header-trailing-whitespace branch April 24, 2025 20:05
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.

Content-length validation does not handle spaces

1 participant