diff options
author | Abhilash Raj <maxking@users.noreply.github.com> | 2019-06-05 12:56:33 -0400 |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2019-06-05 09:56:33 -0700 |
commit | 66c4f3f38b867d8329b28c032bb907fd1a2f22d2 (patch) | |
tree | bed2fe319cf50ffbc6d2ac2c89d5f167df4e9d48 /Lib/test/test_email/test__header_value_parser.py | |
parent | 142566c028720934325f0b7fe28680afd046e00f (diff) | |
download | cpython-git-66c4f3f38b867d8329b28c032bb907fd1a2f22d2.tar.gz |
bpo-21315: Fix parsing of encoded words with missing leading ws. (#13425)
* bpo-21315: Fix parsing of encoded words with missing leading ws.
Because of missing leading whitespace, encoded word would get parsed as
unstructured token. This patch fixes that by looking for encoded words when
splitting tokens with whitespace.
Missing trailing whitespace around encoded word now register a defect
instead.
Original patch suggestion by David R. Murray on bpo-21315.
Diffstat (limited to 'Lib/test/test_email/test__header_value_parser.py')
-rw-r--r-- | Lib/test/test_email/test__header_value_parser.py | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/Lib/test/test_email/test__header_value_parser.py b/Lib/test/test_email/test__header_value_parser.py index 12da3cffb8..649923fa6c 100644 --- a/Lib/test/test_email/test__header_value_parser.py +++ b/Lib/test/test_email/test__header_value_parser.py @@ -118,7 +118,7 @@ class TestParser(TestParserMixin, TestEmailBase): '=?us-ascii?q?first?==?utf-8?q?second?=', 'first', 'first', - [], + [errors.InvalidHeaderDefect], '=?utf-8?q?second?=') def test_get_encoded_word_sets_extra_attributes(self): @@ -361,6 +361,25 @@ class TestParser(TestParserMixin, TestEmailBase): '=?utf-8?q?foo?==?utf-8?q?bar?=', 'foobar', 'foobar', + [errors.InvalidHeaderDefect, + errors.InvalidHeaderDefect], + '') + + def test_get_unstructured_ew_without_leading_whitespace(self): + self._test_get_x( + self._get_unst, + 'nowhitespace=?utf-8?q?somevalue?=', + 'nowhitespacesomevalue', + 'nowhitespacesomevalue', + [errors.InvalidHeaderDefect], + '') + + def test_get_unstructured_ew_without_trailing_whitespace(self): + self._test_get_x( + self._get_unst, + '=?utf-8?q?somevalue?=nowhitespace', + 'somevaluenowhitespace', + 'somevaluenowhitespace', [errors.InvalidHeaderDefect], '') @@ -546,7 +565,8 @@ class TestParser(TestParserMixin, TestEmailBase): '"=?utf-8?Q?not_really_valid?="', '"not really valid"', 'not really valid', - [errors.InvalidHeaderDefect], + [errors.InvalidHeaderDefect, + errors.InvalidHeaderDefect], '') # get_comment |