]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.13] gh-148518 fix index error in local part attribute (GH-148522) (#149199)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 30 Apr 2026 22:13:27 +0000 (00:13 +0200)
committerGitHub <noreply@github.com>
Thu, 30 Apr 2026 22:13:27 +0000 (18:13 -0400)
commit104a38c495da102ddf3b779df78704718e1f517b
treee21fc74f867eba7964fa2a6cfc32f41ac43db9ac
parentb3e0c72fa4a852fccf8d72e9e833798bf087afbb
[3.13] gh-148518 fix index error in local part attribute (GH-148522) (#149199)

As part of fixing bpo-27931 code was introduced to get_bare_quoted_string
that added an empty Terminal if the quoted string was empty.  This isn't
the best answer in terms of the parse tree; we really want the token
list to be empty in that case.  But having it be empty resulted in
local_part raising the index error.  We find that same problem if we
try to parse an address consisting of a single dquote.  By fixing
local_part to not raise on an empty token list, we can have the
bare_quoted_string code correctly return an empty token list for
the empty string cases (two dquotes or a single dquote as the
entire addrespec, at the end of a line).
(cherry picked from commit bdbb55c403d2ab6b4b0a3e994d21b623fee4a544)

Co-authored-by: R. David Murray <rdmurray@bitdance.com>
Lib/email/_header_value_parser.py
Lib/test/test_email/test_headerregistry.py
Misc/NEWS.d/next/Library/2026-04-13-15-59-44.gh-issue-148518.RQdvsu.rst [new file with mode: 0644]