cpython/Lib/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
..
mime gh-126133: Only use start year in PSF copyright, remove end years (#126236) 2024-11-12 15:59:19 +02:00
__init__.py gh-126133: Only use start year in PSF copyright, remove end years (#126236) 2024-11-12 15:59:19 +02:00
_encoded_words.py Correctly fold unknown-8bit originating from encoded words. (#142517) 2025-12-24 09:14:39 -05:00
_header_value_parser.py gh-128110: Fix rfc2047 whitespace handling in email parser address headers (#130749) 2026-05-11 18:20:09 -04:00
_parseaddr.py gh-139434: Update selected RFC 2822 references to RFC 5322 (#139435) 2025-11-04 14:46:07 -05:00
_policybase.py gh-139434: Update selected RFC 2822 references to RFC 5322 (#139435) 2025-11-04 14:46:07 -05:00
architecture.rst Fix typos in multiple .rst files (#1668) 2017-05-19 23:37:57 +03:00
base64mime.py gh-143214: Add the wrapcol parameter in binascii.b2a_base64() and base64.b64encode() (GH-143216) 2026-01-14 14:44:53 +02:00
charset.py gh-126133: Only use start year in PSF copyright, remove end years (#126236) 2024-11-12 15:59:19 +02:00
contentmanager.py gh-143214: Add the wrapcol parameter in binascii.b2a_base64() and base64.b64encode() (GH-143216) 2026-01-14 14:44:53 +02:00
encoders.py gh-126133: Only use start year in PSF copyright, remove end years (#126236) 2024-11-12 15:59:19 +02:00
errors.py gh-81074: Allow non-ASCII addr_spec in email.headerregistry.Address (#122477) 2026-05-01 14:00:46 -04:00
feedparser.py gh-68552: fix defects policy (#138579) 2025-12-06 16:54:29 -05:00
generator.py gh-148192: Fix Generator._make_boundary behavior with CRLF line endings. (#148193) 2026-04-14 09:10:08 -04:00
header.py gh-67022: Document bytes/str inconsistency in email.header.decode_header() and suggest email.headerregistry.HeaderRegistry as a sane alternative (#92900) 2025-06-15 15:29:38 -04:00
headerregistry.py gh-141510: Replace MappingProxyType with frozendict (#144904) 2026-02-18 20:23:49 +00:00
iterators.py gh-126133: Only use start year in PSF copyright, remove end years (#126236) 2024-11-12 15:59:19 +02:00
message.py gh-139434: Update selected RFC 2822 references to RFC 5322 (#139435) 2025-11-04 14:46:07 -05:00
parser.py gh-139434: Update selected RFC 2822 references to RFC 5322 (#139435) 2025-11-04 14:46:07 -05:00
policy.py gh-127794: Validate email header names according to RFC 5322 (#127820) 2025-03-30 12:29:29 +00:00
quoprimime.py gh-145831: email.quoprimime: decode() leaves stray \r when eol='\r\n' (#145832) 2026-04-09 16:21:49 -04:00
utils.py gh-136702: Deprecate passing non-ascii *encoding* (str) to encodings.normalize_encoding (#140030) 2025-11-09 13:37:34 +01:00