mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
#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.
This commit is contained in:
parent
905c8c3d8d
commit
0400d33928
4 changed files with 29 additions and 0 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue