summaryrefslogtreecommitdiffstats
path: root/Lib/email
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-01-29 22:27:55 (GMT)
committerMariatta <Mariatta@users.noreply.github.com>2018-01-29 22:27:55 (GMT)
commit6ea75b174da0cf824e2acc5db6b53798f5f4e4f9 (patch)
tree98c7edeeae50796d7f94e03105c63e3074afe4a5 /Lib/email
parent586986182343eb7475046a5429a1a0e1f368c7ea (diff)
downloadcpython-6ea75b174da0cf824e2acc5db6b53798f5f4e4f9.zip
cpython-6ea75b174da0cf824e2acc5db6b53798f5f4e4f9.tar.gz
cpython-6ea75b174da0cf824e2acc5db6b53798f5f4e4f9.tar.bz2
bpo-27931: Fix email address header parsing error (GH-5329) (GH-5431)
Correctly handle addresses whose username is an empty quoted string. (cherry picked from commit aa218d1649690d1c1ba86a9972f7fae646bf1a8f) Co-authored-by: jayyyin <jayyin11043@hotmail.com>
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/_header_value_parser.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/email/_header_value_parser.py b/Lib/email/_header_value_parser.py
index 3ebbbe5..b23c897 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 '<>'
@@ -1165,6 +1168,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)