summaryrefslogtreecommitdiffstats
path: root/Lib/email
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-06-26 22:05:36 (GMT)
committerBarry Warsaw <barry@python.org>2019-06-26 22:05:36 (GMT)
commit82654a037211a3466a294d53952926fc87f8403d (patch)
tree45a1c38b23e52963954dc0308b6d64e290e93fb5 /Lib/email
parent04d4692579cc4e0204c7fbced3692f8aa4bbb857 (diff)
downloadcpython-82654a037211a3466a294d53952926fc87f8403d.zip
cpython-82654a037211a3466a294d53952926fc87f8403d.tar.gz
cpython-82654a037211a3466a294d53952926fc87f8403d.tar.bz2
bpo-29412: Fix indexError when parsing a header value ending unexpectedly (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 7213df7bbfd85378c6e42e1ac63144d5974bdcf6) Co-authored-by: Abhilash Raj <maxking@users.noreply.github.com>
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/_header_value_parser.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/email/_header_value_parser.py b/Lib/email/_header_value_parser.py
index 308db4d..d9f592b 100644
--- a/Lib/email/_header_value_parser.py
+++ b/Lib/email/_header_value_parser.py
@@ -1339,6 +1339,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: