cpython/Lib/email
Łukasz Langa 06f28dc236
[3.10] gh-121650: Encode newlines in headers, and verify headers are sound (GH-122233) (#122609)
Per RFC 2047:

> [...] these encoding schemes allow the
> encoding of arbitrary octet values, mail readers that implement this
> decoding should also ensure that display of the decoded data on the
> recipient's terminal will not cause unwanted side-effects

It seems that the "quoted-word" scheme is a valid way to include
a newline character in a header value, just like we already allow
undecodable bytes or control characters.
They do need to be properly quoted when serialized to text, though.

This should fail for custom fold() implementations that aren't careful
about newlines.

(cherry picked from commit 0976339818)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Bas Bloemsaat <bas@bloemsaat.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-09-04 17:38:31 +02:00
..
mime [3.10] gh-101021: Document binary parameters as bytes (GH-101024). (#101052) 2023-01-14 21:31:59 -08:00
__init__.py #22508: Drop email __version__ string. It no longer means anything. 2014-10-03 13:02:47 -04:00
_encoded_words.py bpo-43323: Fix UnicodeEncodeError in the email module (GH-32137) 2022-04-30 05:31:28 -07:00
_header_value_parser.py [3.10] gh-121650: Encode newlines in headers, and verify headers are sound (GH-122233) (#122609) 2024-09-04 17:38:31 +02:00
_parseaddr.py gh-95087: Fix IndexError in parsing invalid date in the email module (GH-95201) 2022-07-24 23:39:00 -07:00
_policybase.py [3.10] gh-121650: Encode newlines in headers, and verify headers are sound (GH-122233) (#122609) 2024-09-04 17:38:31 +02:00
architecture.rst Fix typos in multiple .rst files (#1668) 2017-05-19 23:37:57 +03:00
base64mime.py bpo-43125: Fix: return expected type (str), not original value (bytes) in email/base64mime.py::body_encode (GH-24476) 2021-03-30 17:37:37 +09:00
charset.py [3.10] gh-77630: Change Charset to charset (GH-92439) (GH-92476) 2022-05-08 08:28:06 -07:00
contentmanager.py [3.10] bpo-45060: Get rid of few uses of the equality operators with None (GH-28087). (GH-28092) 2021-09-03 21:13:00 -04:00
encoders.py #19957: Simplify encode_7or8bit now that _payload is always str. 2013-12-12 21:40:20 -05:00
errors.py [3.10] gh-121650: Encode newlines in headers, and verify headers are sound (GH-122233) (#122609) 2024-09-04 17:38:31 +02:00
feedparser.py bpo-30835: email: Fix AttributeError when parsing invalid CTE (GH-13598) 2019-06-04 11:00:47 -07:00
generator.py [3.10] gh-121650: Encode newlines in headers, and verify headers are sound (GH-122233) (#122609) 2024-09-04 17:38:31 +02:00
header.py bpo-27737: Allow whitespace only headers encoding (#13478) 2019-05-22 21:13:16 -04:00
headerregistry.py Remove comment about a private email.headerregistry (GH-24233) 2021-02-24 17:21:32 -04:00
iterators.py utilize yield from 2012-10-01 12:53:43 -07:00
message.py bpo-42892: fix email multipart attribute error (GH-26903) (GH-27492) 2021-07-30 19:27:06 +02:00
parser.py Fix infinite loop in email folding logic (GH-12732) 2019-07-16 10:50:01 -07:00
policy.py bpo-33524: Fix the folding of email header when max_line_length is 0 or None (#13391) 2019-05-17 15:28:44 -04:00
quoprimime.py bpo-32297: Few misspellings found in Python source code comments. (#4803) 2017-12-14 13:04:53 +02:00
utils.py bpo-27513: email.utils.getaddresses() now handles Header objects (GH-13797) (GH-27242) 2021-07-19 18:54:45 +02:00