diff options
author | Abhilash Raj <maxking@users.noreply.github.com> | 2019-06-26 20:13:02 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2019-06-26 20:13:02 (GMT) |
commit | 7213df7bbfd85378c6e42e1ac63144d5974bdcf6 (patch) | |
tree | 10034147cc523bf1870d95b1d3c21b13bc462c92 /Lib/email/_header_value_parser.py | |
parent | 2a7d596f27b2342caf168a03c95ebf3b56e5dbbd (diff) | |
download | cpython-7213df7bbfd85378c6e42e1ac63144d5974bdcf6.zip cpython-7213df7bbfd85378c6e42e1ac63144d5974bdcf6.tar.gz cpython-7213df7bbfd85378c6e42e1ac63144d5974bdcf6.tar.bz2 |
bpo-29412: Fix indexError when parsing a header value ending unexpectedly (GH-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.
Diffstat (limited to 'Lib/email/_header_value_parser.py')
-rw-r--r-- | Lib/email/_header_value_parser.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/email/_header_value_parser.py b/Lib/email/_header_value_parser.py index bb5ff8d..aefc457 100644 --- a/Lib/email/_header_value_parser.py +++ b/Lib/email/_header_value_parser.py @@ -1360,6 +1360,9 @@ def get_word(value): leader, value = get_cfws(value) else: leader = None + if not value: + raise errors.HeaderParseError( + "Expected 'atom' or 'quoted-string' but found nothing.") if value[0]=='"': token, value = get_quoted_string(value) elif value[0] in SPECIALS: |