summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_email
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2012-05-26 18:31:12 (GMT)
committerR David Murray <rdmurray@bitdance.com>2012-05-26 18:31:12 (GMT)
commit032eed3c4a42ca29de2c07fba2e0555eaff1700c (patch)
tree61a12aaf27af7c9a8a024bb2625c888226c6681c /Lib/test/test_email
parentd785cb3955e61098056a237b6f322bdda1461aa0 (diff)
downloadcpython-032eed3c4a42ca29de2c07fba2e0555eaff1700c.zip
cpython-032eed3c4a42ca29de2c07fba2e0555eaff1700c.tar.gz
cpython-032eed3c4a42ca29de2c07fba2e0555eaff1700c.tar.bz2
Recognize '<>' as a special case of an angle-addr in header_value_parser.
Although '<>' is invalid according to RFC 5322, SMTP uses it for various things, and it sometimes ends up in email headers. This patch changes get_angle_addr to recognize it and just register a Defect instead of raising a parsing error.
Diffstat (limited to 'Lib/test/test_email')
-rw-r--r--Lib/test/test_email/test__header_value_parser.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/Lib/test/test_email/test__header_value_parser.py b/Lib/test/test_email/test__header_value_parser.py
index 75fe299..2161af1 100644
--- a/Lib/test/test_email/test__header_value_parser.py
+++ b/Lib/test/test_email/test__header_value_parser.py
@@ -1429,6 +1429,19 @@ class TestParser(TestEmailBase):
self.assertIsNone(angle_addr.route)
self.assertEqual(angle_addr.addr_spec, 'dinsdale@example.com')
+ def test_get_angle_addr_empty(self):
+ angle_addr = self._test_get_x(parser.get_angle_addr,
+ '<>',
+ '<>',
+ '<>',
+ [errors.InvalidHeaderDefect],
+ '')
+ self.assertEqual(angle_addr.token_type, 'angle-addr')
+ self.assertIsNone(angle_addr.local_part)
+ self.assertIsNone(angle_addr.domain)
+ self.assertIsNone(angle_addr.route)
+ self.assertEqual(angle_addr.addr_spec, '<>')
+
def test_get_angle_addr_with_cfws(self):
angle_addr = self._test_get_x(parser.get_angle_addr,
' (foo) <dinsdale@example.com>(bar)',
@@ -2007,7 +2020,7 @@ class TestParser(TestEmailBase):
self.assertEqual(group.mailboxes,
group.all_mailboxes)
- def test_get_troup_null_addr_spec(self):
+ def test_get_group_null_addr_spec(self):
group = self._test_get_x(parser.get_group,
'foo: <>;',
'foo: <>;',