Skip to content

gh-150726: validate wsgiref Headers control characters under -O#150727

Open
metsw24-max wants to merge 1 commit into
python:mainfrom
metsw24-max:fix-wsgiref-headers-debug-validation
Open

gh-150726: validate wsgiref Headers control characters under -O#150727
metsw24-max wants to merge 1 commit into
python:mainfrom
metsw24-max:fix-wsgiref-headers-debug-validation

Conversation

@metsw24-max
Copy link
Copy Markdown

@metsw24-max metsw24-max commented Jun 1, 2026

Headers.__init__ rejects control characters in header names and values only inside an if __debug__: block, so the check is dropped under -O/-OO. BaseHandler.start_response builds its headers through this constructor, so a CR/LF value reflected from a request passes straight to the response there, splitting it. The other mutators (__setitem__, add_header, setdefault) already validate unconditionally; this makes __init__ match.

Closes #150726

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wsgiref.headers.Headers control-character validation is skipped under -O

1 participant