summaryrefslogtreecommitdiff
path: root/Lib/test/test_email/test__header_value_parser.py
diff options
context:
space:
mode:
authorjpic <jpic@users.noreply.github.com>2019-07-17 23:54:25 +0200
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-07-17 14:54:25 -0700
commit8cb65d1381b027f0b09ee36bfed7f35bb4dec9a9 (patch)
tree66906fde428f0af62b753d529cd28a87c9e7438c /Lib/test/test_email/test__header_value_parser.py
parent719a062bcb7b08a56e6576dcd75f4244e6053209 (diff)
downloadcpython-git-8cb65d1381b027f0b09ee36bfed7f35bb4dec9a9.tar.gz
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
Diffstat (limited to 'Lib/test/test_email/test__header_value_parser.py')
-rw-r--r--Lib/test/test_email/test__header_value_parser.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_email/test__header_value_parser.py b/Lib/test/test_email/test__header_value_parser.py
index 4fa56b16c4..877cd3effe 100644
--- a/Lib/test/test_email/test__header_value_parser.py
+++ b/Lib/test/test_email/test__header_value_parser.py
@@ -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):