Skip to content

Fix cosmetic header validity parsing regex#7308

Merged
nateprewitt merged 1 commit into
psf:mainfrom
nateprewitt:header_validity_fix
Mar 30, 2026
Merged

Fix cosmetic header validity parsing regex#7308
nateprewitt merged 1 commit into
psf:mainfrom
nateprewitt:header_validity_fix

Conversation

@nateprewitt

Copy link
Copy Markdown
Member

Credit to @ParzivalHack for reporting this through our security channel. This PR fixes what is now a cosmetic guard for header validity. It was originally introduced before the standard library handled line folding in http.client to protect older versions of Python. Now it serves as a cleaner error layer for callers of Requests.

This PR moves the end of regex from $ to \Z to capture any end-of-line LF characters. Those are explicitly ignored by $ for convenience and our tests missed it. This change ensures our error is raised uniformly and we don't have standard library error messages sneaking though.

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