mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
bpo-39040: Fix parsing of email mime headers with whitespace between encoded-words. (gh-17620)
* bpo-39040: Fix parsing of email headers with encoded-words inside a quoted string.
It is fairly common to find malformed mime headers (especially content-disposition
headers) where the parameter values, instead of being encoded to RFC
standards, are "encoded" by doing RFC 2047 "encoded word" encoding, and
then enclosing the whole thing in quotes. The processing of these malformed
headers was incorrectly leaving the spaces between encoded words in the decoded
text (whitespace between adjacent encoded words is supposed to be stripped on
decoding). This changeset fixes the encoded word processing inside quoted strings
(bare-quoted-string) to do correct RFC 2047 decoding by stripping that
whitespace.
(cherry picked from commit 21017ed904
)
Co-authored-by: Abhilash Raj <maxking@users.noreply.github.com>
This commit is contained in:
parent
8e5f11d1f8
commit
a6ae02d7e9
3 changed files with 30 additions and 0 deletions
|
@ -873,6 +873,25 @@ class TestContentDisposition(TestHeaderBase):
|
|||
{'filename': 'foo'},
|
||||
[errors.InvalidHeaderDefect]),
|
||||
|
||||
'invalid_parameter_value_with_fws_between_ew': (
|
||||
'attachment; filename="=?UTF-8?Q?Schulbesuchsbest=C3=A4ttigung=2E?='
|
||||
' =?UTF-8?Q?pdf?="',
|
||||
'attachment',
|
||||
{'filename': 'Schulbesuchsbestättigung.pdf'},
|
||||
[errors.InvalidHeaderDefect]*3,
|
||||
('attachment; filename="Schulbesuchsbestättigung.pdf"'),
|
||||
('Content-Disposition: attachment;\n'
|
||||
' filename*=utf-8\'\'Schulbesuchsbest%C3%A4ttigung.pdf\n'),
|
||||
),
|
||||
|
||||
'parameter_value_with_fws_between_tokens': (
|
||||
'attachment; filename="File =?utf-8?q?Name?= With Spaces.pdf"',
|
||||
'attachment',
|
||||
{'filename': 'File Name With Spaces.pdf'},
|
||||
[errors.InvalidHeaderDefect],
|
||||
'attachment; filename="File Name With Spaces.pdf"',
|
||||
('Content-Disposition: attachment; filename="File Name With Spaces.pdf"\n'),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue