bpo-29412: Fix indexError when parsing a header value ending unexpectedly#14387
bpo-29412: Fix indexError when parsing a header value ending unexpectedly#14387warsaw merged 4 commits intopython:masterfrom
Conversation
…er_value_parser.py and created tests in test__header_value_parser.py for CFWS.
|
To mention this borrows a test case from GH-6907 (which seeems to be abandoned, which is why I am proposing this new PR to override that). The fix however is different than GH-6907, which is why I haven't added a |
Also, modify the testcase.
2941cb3 to
e28cbc9
Compare
| leader, value = get_cfws(value) | ||
| else: | ||
| leader = None | ||
| if not value: |
There was a problem hiding this comment.
Do you want to catch all false-y values or just None?
There was a problem hiding this comment.
I want to catch None and empty string '' values, both of which could cause IndexError when running value[0]. It could also be caused by empty list, empty tuple etc etc, but I don't think value can be of those datatypes.
Remove implicit concatenation of strings and move the string to next line so that it can fit properly under 79 chars.
|
I'm assuming this needs backporting to 3.7 and 3.8. |
…edly (pythonGH-14387) * patched string index out of range error in get_word function of _header_value_parser.py and created tests in test__header_value_parser.py for CFWS. * Raise HeaderParseError instead of continuing when parsing a word. (cherry picked from commit 7213df7) Co-authored-by: Abhilash Raj <maxking@users.noreply.github.com>
|
GH-14411 is a backport of this pull request to the 3.8 branch. |
|
GH-14412 is a backport of this pull request to the 3.7 branch. |
…edly (pythonGH-14387) * patched string index out of range error in get_word function of _header_value_parser.py and created tests in test__header_value_parser.py for CFWS. * Raise HeaderParseError instead of continuing when parsing a word. (cherry picked from commit 7213df7) Co-authored-by: Abhilash Raj <maxking@users.noreply.github.com>
…edly (GH-14387) (GH-14412) * patched string index out of range error in get_word function of _header_value_parser.py and created tests in test__header_value_parser.py for CFWS. * Raise HeaderParseError instead of continuing when parsing a word. (cherry picked from commit 7213df7) Co-authored-by: Abhilash Raj <maxking@users.noreply.github.com>
…edly (GH-14387) (GH-14411) * patched string index out of range error in get_word function of _header_value_parser.py and created tests in test__header_value_parser.py for CFWS. * Raise HeaderParseError instead of continuing when parsing a word. (cherry picked from commit 7213df7) Co-authored-by: Abhilash Raj <maxking@users.noreply.github.com>
…edly (pythonGH-14387) * patched string index out of range error in get_word function of _header_value_parser.py and created tests in test__header_value_parser.py for CFWS. * Raise HeaderParseError instead of continuing when parsing a word.
…edly (pythonGH-14387) * patched string index out of range error in get_word function of _header_value_parser.py and created tests in test__header_value_parser.py for CFWS. * Raise HeaderParseError instead of continuing when parsing a word.
When parsing a word, if the value is None, we should raise
HeaderParseErrorinstead of continuing silently. This helps fix the IndexError.Part of the patch is from GH-6907, so thanks to @TyrannosourceExe.
https://bugs.python.org/issue29412