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
This commit is contained in:
jpic 2019-07-17 23:54:25 +02:00 committed by Miss Islington (bot)
parent 719a062bcb
commit 8cb65d1381
5 changed files with 37 additions and 1 deletions

View file

@ -1448,6 +1448,16 @@ class TestParser(TestParserMixin, TestEmailBase):
self.assertEqual(addr_spec.domain, 'example.com')
self.assertEqual(addr_spec.addr_spec, 'star.a.star@example.com')
def test_get_addr_spec_multiple_domains(self):
with self.assertRaises(errors.HeaderParseError):
parser.get_addr_spec('star@a.star@example.com')
with self.assertRaises(errors.HeaderParseError):
parser.get_addr_spec('star@a@example.com')
with self.assertRaises(errors.HeaderParseError):
parser.get_addr_spec('star@172.17.0.1@example.com')
# get_obs_route
def test_get_obs_route_simple(self):