mirror of
https://github.com/python/cpython.git
synced 2025-08-19 00:00:48 +00:00
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 8cb65d1381
)
Co-authored-by: jpic <jpic@users.noreply.github.com>
This commit is contained in:
parent
162d45c531
commit
217077440a
5 changed files with 37 additions and 1 deletions
|
@ -3041,6 +3041,20 @@ class TestMiscellaneous(TestEmailBase):
|
|||
self.assertEqual(utils.parseaddr('<>'), ('', ''))
|
||||
self.assertEqual(utils.formataddr(utils.parseaddr('<>')), '')
|
||||
|
||||
def test_parseaddr_multiple_domains(self):
|
||||
self.assertEqual(
|
||||
utils.parseaddr('a@b@c'),
|
||||
('', '')
|
||||
)
|
||||
self.assertEqual(
|
||||
utils.parseaddr('a@b.c@c'),
|
||||
('', '')
|
||||
)
|
||||
self.assertEqual(
|
||||
utils.parseaddr('a@172.17.0.1@c'),
|
||||
('', '')
|
||||
)
|
||||
|
||||
def test_noquote_dump(self):
|
||||
self.assertEqual(
|
||||
utils.formataddr(('A Silly Person', 'person@dom.ain')),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue