diff options
author | Abhilash Raj <maxking@users.noreply.github.com> | 2019-09-07 05:24:05 (GMT) |
---|---|---|
committer | larryhastings <larry@hastings.org> | 2019-09-07 05:24:05 (GMT) |
commit | 063eba280a11d3c9a5dd9ee5abe4de640907951b (patch) | |
tree | 93e0401521e7d4a597278c48d8dd9f5e6c092f47 /Lib/email/_parseaddr.py | |
parent | afe3a4975cf93c97e5d6eb8800e48f368011d37a (diff) | |
download | cpython-063eba280a11d3c9a5dd9ee5abe4de640907951b.zip cpython-063eba280a11d3c9a5dd9ee5abe4de640907951b.tar.gz cpython-063eba280a11d3c9a5dd9ee5abe4de640907951b.tar.bz2 |
[3.5] bpo-34155: Dont parse domains containing @ (GH-13079) (#15317)
https://bugs.python.org/issue34155
(cherry picked from commit 8cb65d1381b027f0b09ee36bfed7f35bb4dec9a9)
Co-authored-by: jpic <jpic@users.noreply.github.com>
Diffstat (limited to 'Lib/email/_parseaddr.py')
-rw-r--r-- | Lib/email/_parseaddr.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/email/_parseaddr.py b/Lib/email/_parseaddr.py index cdfa372..41ff6f8 100644 --- a/Lib/email/_parseaddr.py +++ b/Lib/email/_parseaddr.py @@ -379,7 +379,12 @@ class AddrlistClass: aslist.append('@') self.pos += 1 self.gotonext() - return EMPTYSTRING.join(aslist) + self.getdomain() + domain = self.getdomain() + if not domain: + # Invalid domain, return an empty address instead of returning a + # local part to denote failed parsing. + return EMPTYSTRING + return EMPTYSTRING.join(aslist) + domain def getdomain(self): """Get the complete domain name from an address.""" @@ -394,6 +399,10 @@ class AddrlistClass: elif self.field[self.pos] == '.': self.pos += 1 sdlist.append('.') + elif self.field[self.pos] == '@': + # bpo-34155: Don't parse domains with two `@` like + # `a@malicious.org@important.com`. + return EMPTYSTRING elif self.field[self.pos] in self.atomends: break else: |