← 输入框|github.com|刷新
Skip to content

reqs: replace obs-fold line breaks with spaces - #630

Open
prownd wants to merge 1 commit into
tinyproxy:masterfrom
prownd:reqs-replace-obs-fold-line-breaks-with-spaces-s01
Open

prownd wants to merge 1 commit into
tinyproxy:masterfrom
prownd:reqs-replace-obs-fold-line-breaks-with-spaces-s01

Conversation

@prownd

@prownd prownd commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

get_all_headers() joins folded header lines (obs-fold) by simply concatenating them, so the CR LF of the first line ends up inside the header value which is then forwarded as-is:

X-Folded: a\r\n b

RFC 9112 section 5.2 requires a proxy to either reject such a message or to replace each obs-fold with one or more SP octets before forwarding it. Forwarding raw line breaks lets differently implemented hops disagree on the header set (e.g. with a folded Content-Length).

Replace the line break preceding a continuation line with spaces.

get_all_headers() joins folded header lines (obs-fold) by simply
concatenating them, so the CR LF of the first line ends up inside the
header value which is then forwarded as-is:

    X-Folded: a\r\n b

RFC 9112 section 5.2 requires a proxy to either reject such a message
or to replace each obs-fold with one or more SP octets before
forwarding it.  Forwarding raw line breaks lets differently implemented
hops disagree on the header set (e.g. with a folded Content-Length).

Replace the line break preceding a continuation line with spaces.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The focused change safely normalizes folded headers for both request and response forwarding.

Review effort: Balanced
Findings: None

What changed in this PR

Normalizes obsolete folded HTTP headers to prevent forwarding embedded CR/LF characters.

Changes:

  • Replaces folded-header CR/LF bytes with spaces per RFC 9112 §5.2.
File Description
src/​reqs.c Normalizes obs-fold line breaks during header parsing.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

2 participants