summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_email/test__header_value_parser.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2014-02-08 18:12:00 (GMT)
committerR David Murray <rdmurray@bitdance.com>2014-02-08 18:12:00 (GMT)
commit0400d33928e6b463db164836da670700f03edc5d (patch)
tree70c96ca143468dfe5e7fcfc827fc32bf37d4ff4b /Lib/test/test_email/test__header_value_parser.py
parent905c8c3d8dfe081d91e399aa5fd93d1659655264 (diff)
downloadcpython-0400d33928e6b463db164836da670700f03edc5d.zip
cpython-0400d33928e6b463db164836da670700f03edc5d.tar.gz
cpython-0400d33928e6b463db164836da670700f03edc5d.tar.bz2
#16983: Apply postel's law to encoded words inside quoted strings.
This applies only to the new parser. The old parser decodes encoded words inside quoted strings already, although it gets the whitespace wrong when it does so. This version of the patch only handles the most common case (a single encoded word surrounded by quotes), but I haven't seen any other variations of this in the wild yet, so its good enough for now.
Diffstat (limited to 'Lib/test/test_email/test__header_value_parser.py')
-rw-r--r--Lib/test/test_email/test__header_value_parser.py9
1 files changed, 9 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 646082b..32996ca 100644
--- a/Lib/test/test_email/test__header_value_parser.py
+++ b/Lib/test/test_email/test__header_value_parser.py
@@ -540,6 +540,15 @@ class TestParser(TestParserMixin, TestEmailBase):
self._test_get_x(parser.get_bare_quoted_string,
'""', '""', '', [], '')
+ # Issue 16983: apply postel's law to some bad encoding.
+ def test_encoded_word_inside_quotes(self):
+ self._test_get_x(parser.get_bare_quoted_string,
+ '"=?utf-8?Q?not_really_valid?="',
+ '"not really valid"',
+ 'not really valid',
+ [errors.InvalidHeaderDefect],
+ '')
+
# get_comment
def test_get_comment_only(self):