diff options
author | jayyyin <jayyin11043@hotmail.com> | 2018-01-29 18:07:44 (GMT) |
---|---|---|
committer | R. David Murray <rdmurray@bitdance.com> | 2018-01-29 18:07:44 (GMT) |
commit | aa218d1649690d1c1ba86a9972f7fae646bf1a8f (patch) | |
tree | df45b81a6791ca716a65a56693db18a2a4e5415d /Lib/email | |
parent | e6d342156d2ab20fb88c0a5ec615fa8f602c0769 (diff) | |
download | cpython-aa218d1649690d1c1ba86a9972f7fae646bf1a8f.zip cpython-aa218d1649690d1c1ba86a9972f7fae646bf1a8f.tar.gz cpython-aa218d1649690d1c1ba86a9972f7fae646bf1a8f.tar.bz2 |
bpo-27931: Fix email address header parsing error (#5329)
Correctly handle addresses whose username is an empty quoted string.
Diffstat (limited to 'Lib/email')
-rw-r--r-- | Lib/email/_header_value_parser.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/email/_header_value_parser.py b/Lib/email/_header_value_parser.py index b34c58b..d2d1f5c 100644 --- a/Lib/email/_header_value_parser.py +++ b/Lib/email/_header_value_parser.py @@ -430,7 +430,10 @@ class AngleAddr(TokenList): def addr_spec(self): for x in self: if x.token_type == 'addr-spec': - return x.addr_spec + if x.local_part: + return x.addr_spec + else: + return quote_string(x.local_part) + x.addr_spec else: return '<>' @@ -1164,6 +1167,9 @@ def get_bare_quoted_string(value): "expected '\"' but found '{}'".format(value)) bare_quoted_string = BareQuotedString() value = value[1:] + if value[0] == '"': + token, value = get_qcontent(value) + bare_quoted_string.append(token) while value and value[0] != '"': if value[0] in WSP: token, value = get_fws(value) |