cpython/Lib/test/test_email
Mike Edmunds 7a4c6dfb88
gh-128110: Fix rfc2047 whitespace handling in email parser address headers (#130749)
RFC 2047 Section 6.2 requires that "any 'linear-white-space' that
separates a pair of adjacent 'encoded-word's is ignored." The modern
header value parser correctly implements that for unstructured headers,
but had missed a case in structured headers. This could cause a parsed
address header to include extraneous spaces in a display-name.

Switch to @bitdancer's fix from review feedback. Recharacterize space
between ews as fws after parsing in get_phrase.

RDM: This fix is dependent on the fact that "subsequent" atoms will never have
leading whitespace because that's been consumed already. I don't think
it's worth adding extra code for the possibility of leading whitespace
because the parser won't produce it. It's a bit of parser fragility in the
face of code changes, but I think that's a minor concern given the 
parser design (which is that it consumes whitespace greedily)

Co-authored-by: R David Murray <rdmurray@bitdance.com>
2026-05-11 18:20:09 -04:00
..
data
__init__.py
__main__.py
test__encoded_words.py
test__header_value_parser.py gh-128110: Fix rfc2047 whitespace handling in email parser address headers (#130749) 2026-05-11 18:20:09 -04:00
test_asian_codecs.py
test_contentmanager.py
test_defect_handling.py
test_email.py gh-145831: email.quoprimime: decode() leaves stray \r when eol='\r\n' (#145832) 2026-04-09 16:21:49 -04:00
test_generator.py gh-83938, gh-122476: Stop incorrectly RFC 2047 encoding non-ASCII email addresses (#122540) 2026-05-01 13:52:06 -04:00
test_headerregistry.py gh-81074: Allow non-ASCII addr_spec in email.headerregistry.Address (#122477) 2026-05-01 14:00:46 -04:00
test_inversion.py
test_message.py
test_parser.py
test_pickleable.py
test_policy.py
test_utils.py
torture_test.py