cpython/Lib/test/test_email
Miss Islington (bot) 4aaa4259b5
[3.13] gh-121650: Encode newlines in headers, and verify headers are sound (GH-122233) (#122484)
gh-121650: Encode newlines in headers, and verify headers are sound (GH-122233)

GH-GH- Encode header parts that contain newlines

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.

GH-GH- Verify that email headers are well-formed

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-08-06 19:06:41 +02:00
..
data gh-106186: Don't report MultipartInvariantViolationDefect for valid multipart emails when parsing header only (#107016) 2023-07-23 12:25:18 +02:00
__init__.py
__main__.py
test__encoded_words.py
test__header_value_parser.py [3.13] gh-118643: Fix AttributeError in the email module (GH-119099) (GH-119389) 2024-05-22 14:07:38 +03:00
test_asian_codecs.py
test_contentmanager.py
test_defect_handling.py
test_email.py gh-80361: Fix TypeError in email.Message.get_payload() (GH-117994) 2024-04-17 19:31:26 +03:00
test_generator.py [3.13] gh-121650: Encode newlines in headers, and verify headers are sound (GH-122233) (#122484) 2024-08-06 19:06:41 +02:00
test_headerregistry.py [3.13] gh-92081: Fix for email.generator.Generator with whitespace between encoded words. (GH-92281) (#119245) 2024-05-20 20:01:56 +00:00
test_inversion.py
test_message.py gh-94606: Fix error when message with Unicode surrogate not surrogateescaped string (GH-94641) 2023-12-11 18:21:18 +02:00
test_parser.py
test_pickleable.py
test_policy.py [3.13] gh-121650: Encode newlines in headers, and verify headers are sound (GH-122233) (#122484) 2024-08-06 19:06:41 +02:00
test_utils.py gh-113027: Fix timezone check in test_variable_tzname in test_email (GH-113835) 2024-01-12 11:46:17 +01:00
torture_test.py