Repository navigation
Fix http-headers crash on whitespace-only lines - #753
Merged
kellyjonbrazil merged 2 commits intoSep 15, 2026
Merged
kellyjonbrazil merged 2 commits into
kellyjonbrazil merged 2 commits into
Conversation
The parser skipped empty lines with filter(None, ...), which still let a whitespace-only line reach line.split(maxsplit=1)[0] and raise IndexError. Filter the lines the same way the hosts parser does.
Owner
|
Looks good - thanks for the contribution. This will make it to the next release. |
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.
Fixes #752.
http_headersdropped empty lines withfilter(None, ...), which still lets a whitespace-only line through tofirst_word = line.split(maxsplit=1)[0], raisingIndexError.curl_headreaches the same line throughhttp_headers.parse.The lines are now filtered the way
hostsis after #743.Two tests were added, one for a request and one for a response containing a whitespace-only line. Both raise the
IndexErrorondevand pass with the change.tests/test_http_headers.pyruns 4 tests; a fullpython -m unittest discover testsreports the same failures before and after the change in this environment.