diff options
| author | jayyyin <jayyin11043@hotmail.com> | 2018-01-29 18:07:44 (GMT) |
|---|---|---|
| committer | R. David Murray <rdmurray@bitdance.com> | 2018-01-29 18:07:44 (GMT) |
| commit | aa218d1649690d1c1ba86a9972f7fae646bf1a8f (patch) | |
| tree | df45b81a6791ca716a65a56693db18a2a4e5415d /Lib/test | |
| parent | e6d342156d2ab20fb88c0a5ec615fa8f602c0769 (diff) | |
| download | cpython-aa218d1649690d1c1ba86a9972f7fae646bf1a8f.zip cpython-aa218d1649690d1c1ba86a9972f7fae646bf1a8f.tar.gz cpython-aa218d1649690d1c1ba86a9972f7fae646bf1a8f.tar.bz2 | |
bpo-27931: Fix email address header parsing error (#5329)
Correctly handle addresses whose username is an empty quoted string.
Diffstat (limited to 'Lib/test')
| -rw-r--r-- | Lib/test/test_email/test__header_value_parser.py | 17 |
1 files changed, 17 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 1667617..5cdc4bc 100644 --- a/Lib/test/test_email/test__header_value_parser.py +++ b/Lib/test/test_email/test__header_value_parser.py @@ -490,6 +490,10 @@ class TestParser(TestParserMixin, TestEmailBase): with self.assertRaises(errors.HeaderParseError): parser.get_bare_quoted_string(' "foo"') + def test_get_bare_quoted_string_only_quotes(self): + self._test_get_x(parser.get_bare_quoted_string, + '""', '""', '', [], '') + def test_get_bare_quoted_string_following_wsp_preserved(self): self._test_get_x(parser.get_bare_quoted_string, '"foo"\t bar', '"foo"', 'foo', [], '\t bar') @@ -1467,6 +1471,19 @@ class TestParser(TestParserMixin, TestEmailBase): self.assertIsNone(angle_addr.route) self.assertEqual(angle_addr.addr_spec, '<>') + def test_get_angle_addr_qs_only_quotes(self): + angle_addr = self._test_get_x(parser.get_angle_addr, + '<""@example.com>', + '<""@example.com>', + '<""@example.com>', + [], + '') + self.assertEqual(angle_addr.token_type, 'angle-addr') + self.assertEqual(angle_addr.local_part, '') + self.assertEqual(angle_addr.domain, 'example.com') + self.assertIsNone(angle_addr.route) + self.assertEqual(angle_addr.addr_spec, '""@example.com') + def test_get_angle_addr_with_cfws(self): angle_addr = self._test_get_x(parser.get_angle_addr, ' (foo) <dinsdale@example.com>(bar)', |
