summaryrefslogtreecommitdiffstats
path: root/Lib/email/_header_value_parser.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-08-09 08:31:27 (GMT)
committerGitHub <noreply@github.com>2019-08-09 08:31:27 (GMT)
commit217077440a6938a0b428f67cfef6e053c4f8673c (patch)
tree807fe1dec29b39f7abb62556893b93397160e287 /Lib/email/_header_value_parser.py
parent162d45c531552d0699f945d2c22a763941dca3c1 (diff)
downloadcpython-217077440a6938a0b428f67cfef6e053c4f8673c.zip
cpython-217077440a6938a0b428f67cfef6e053c4f8673c.tar.gz
cpython-217077440a6938a0b428f67cfef6e053c4f8673c.tar.bz2
bpo-34155: Dont parse domains containing @ (GH-13079)
Before: >>> email.message_from_string('From: a@malicious.org@important.com', policy=email.policy.default)['from'].addresses (Address(display_name='', username='a', domain='malicious.org'),) >>> parseaddr('a@malicious.org@important.com') ('', 'a@malicious.org') After: >>> email.message_from_string('From: a@malicious.org@important.com', policy=email.policy.default)['from'].addresses (Address(display_name='', username='', domain=''),) >>> parseaddr('a@malicious.org@important.com') ('', 'a@') https://bugs.python.org/issue34155 (cherry picked from commit 8cb65d1381b027f0b09ee36bfed7f35bb4dec9a9) Co-authored-by: jpic <jpic@users.noreply.github.com>
Diffstat (limited to 'Lib/email/_header_value_parser.py')
-rw-r--r--Lib/email/_header_value_parser.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/email/_header_value_parser.py b/Lib/email/_header_value_parser.py
index 7dfd978..a930792 100644
--- a/Lib/email/_header_value_parser.py
+++ b/Lib/email/_header_value_parser.py
@@ -1566,6 +1566,8 @@ def get_domain(value):
token, value = get_dot_atom(value)
except errors.HeaderParseError:
token, value = get_atom(value)
+ if value and value[0] == '@':
+ raise errors.HeaderParseError('Invalid Domain')
if leader is not None:
token[:0] = [leader]
domain.append(token)