diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-08-11 14:04:31 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-11 14:04:31 -0700 |
commit | 9500bbe9372f6080decc49d2fd9365f0b927a0e2 (patch) | |
tree | ccc4bc441185a56739a190c80588ac43abda052e /Lib/test/test_email | |
parent | c61f9b57cfce9e96bdea5674634e3a9c185b675f (diff) | |
download | cpython-git-9500bbe9372f6080decc49d2fd9365f0b927a0e2.tar.gz |
bpo-32178: Fix IndexError trying to parse 'To' header starting with ':'. (GH-15044)
This should fix the IndexError trying to retrieve `DisplayName.display_name` and `DisplayName.value` when the `value` is basically an empty string.
https://bugs.python.org/issue32178
(cherry picked from commit 09a1872a8007048dcdf825a476816c5e3498b8f8)
Co-authored-by: Abhilash Raj <maxking@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_email')
-rw-r--r-- | Lib/test/test_email/test__header_value_parser.py | 8 |
1 files changed, 8 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 010be9fa4a..198cf17bbf 100644 --- a/Lib/test/test_email/test__header_value_parser.py +++ b/Lib/test/test_email/test__header_value_parser.py @@ -1680,6 +1680,14 @@ class TestParser(TestParserMixin, TestEmailBase): self.assertEqual(display_name[3].comments, ['with trailing comment']) self.assertEqual(display_name.display_name, 'simple phrase.') + def test_get_display_name_for_invalid_address_field(self): + # bpo-32178: Test that address fields starting with `:` don't cause + # IndexError when parsing the display name. + display_name = self._test_get_x( + parser.get_display_name, + ':Foo ', '', '', [errors.InvalidHeaderDefect], ':Foo ') + self.assertEqual(display_name.value, '') + # get_name_addr def test_get_name_addr_angle_addr_only(self): |