mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-27931: Fix email address header parsing error (#5329)
Correctly handle addresses whose username is an empty quoted string.
This commit is contained in:
parent
e6d342156d
commit
aa218d1649
3 changed files with 25 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue