cpython/Lib/email
Miss Islington (bot) 20175bbeba
[3.14] gh-128110: Fix rfc2047 whitespace handling in email parser address headers (GH-130749) (#149788)
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)
(cherry picked from commit 7a4c6dfb88)

Co-authored-by: Mike Edmunds <medmunds@gmail.com>
Co-authored-by: R David Murray <rdmurray@bitdance.com>
2026-05-13 16:28:22 -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 [3.14] Correctly fold unknown-8bit originating from encoded words. (GH-142517) (#143146) 2025-12-24 13:20:05 -05:00
_header_value_parser.py [3.14] gh-128110: Fix rfc2047 whitespace handling in email parser address headers (GH-130749) (#149788) 2026-05-13 16:28:22 -04:00
_parseaddr.py [3.14] gh-139434: Update selected RFC 2822 references to RFC 5322 (GH-139435) (#141025) 2025-11-04 16:23:16 -05:00
_policybase.py [3.14] gh-139434: Update selected RFC 2822 references to RFC 5322 (GH-139435) (#141025) 2025-11-04 16:23:16 -05:00
architecture.rst
base64mime.py gh-126133: Only use start year in PSF copyright, remove end years (#126236) 2024-11-12 15:59:19 +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 [3.14] gh-135307: Fix email error when policy max_line_length is set to 0 or None (GH-135367) (#140915) 2025-11-02 10:03:12 -05: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-126133: Only use start year in PSF copyright, remove end years (#126236) 2024-11-12 15:59:19 +02:00
feedparser.py [3.14] gh-68552: fix defects policy (GH-138579) (#142366) 2025-12-09 07:39:01 +00:00
generator.py [3.14] gh-148192: Fix Generator._make_boundary behavior with CRLF line endings. (GH-148193) (#148550) 2026-04-14 12:04:50 -04:00
header.py [3.14] gh-67022: Document bytes/str inconsistency in email.header.decode_header() and suggest email.headerregistry.HeaderRegistry as a sane alternative (GH-92900) (#135548) 2025-06-15 16:02:16 -04:00
headerregistry.py [3.14] gh-79986: Add parsing for References/In-Reply-To email headers (GH-137201) (#142573) 2025-12-21 14:35:24 -05: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 [3.14] gh-136063: fix quadratic-complexity parsing in email.message._parseparam (GH-136072) (#140827) 2025-11-30 14:30:56 +02:00
parser.py [3.14] gh-139434: Update selected RFC 2822 references to RFC 5322 (GH-139435) (#141025) 2025-11-04 16:23:16 -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 [3.14] gh-145831: email.quoprimime: decode() leaves stray \r when eol='\r\n' (GH-145832) (#148312) 2026-04-10 08:49:59 -04:00
utils.py [3.14] gh-134151 Fix TypeError in email.utils.decode_params when sorting RFC 2231 continuations (GH-134687) (#135247) 2025-06-08 07:38:39 +00:00