Repository navigation
Reject whitespace after HTTP request versions - #893
Open
Aschenbath wants to merge 1 commit into
Open
Aschenbath wants to merge 1 commit into
Aschenbath wants to merge 1 commit into
Conversation
The request-line grammar places CRLF directly after HTTP-version. Stripping the entire line and letting int() trim its input accepts extra whitespace, which can disagree with other HTTP recipients. cherrypy#717 Assisted-by: LLM
Automation signalsActivity patterns show signs of automation. Evidence
Last 5 PRs: This is an automated analysis by AgentScan |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #893 +/- ##
==========================================
- Coverage 76.11% 76.10% -0.02%
==========================================
Files 41 42 +1
Lines 4932 4955 +23
Branches 561 561
==========================================
+ Hits 3754 3771 +17
- Misses 1040 1045 +5
- Partials 138 139 +1 |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
What do these changes do?
Preserve request-line whitespace while splitting off CRLF, then reject whitespace after the HTTP version. Previously, stripping the complete line accepted inputs such as
GET / HTTP/1.1 <CRLF>. The explicit check also prevents integer conversion from accepting trailing whitespace.Are there changes in behavior for the user?
Malformed request lines receive
400 Bad Requestbefore version negotiation. Valid HTTP/1.0 and HTTP/1.1 requests remain supported; an otherwise valid unsupported version still receives 505.Is it a substantial burden for the maintainers to support this?
This is a local parsing check with eleven real-socket regression cases. Eight fail before the fix; all eleven pass in the full suite after it.
Validation through tox on Windows/Python 3.12: 211 passed, 11 existing skips, 4 existing expected failures, and one TLS client-auth error-text failure. The TLS error-text failure category was also reproduced on unmodified server.py. All applicable pre-commit hooks passed; the existing tox reporting snippets fail afterward on unescaped Windows paths. No checks were relaxed.
AI assistance: Codex implemented and tested this change locally.
Related issue number
Fixes #717.
Checklist
Tip
New to open source contributions? Making a lovely PR is a great read.
and description in grammatically correct, complete sentences
docs/) and inline docstrings reflect the changes(see good commit messages)
(can be done once the PR number is known; alternatively, you can
use a related issue number if one exists)
code of conduct