]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-134152: Fix UnboundLocalError in email._header_value_parser _get_ptext_to_endchars...
authorR. David Murray <rdmurray@bitdance.com>
Sun, 25 May 2025 22:09:32 +0000 (18:09 -0400)
committerGitHub <noreply@github.com>
Sun, 25 May 2025 22:09:32 +0000 (18:09 -0400)
commita32ea456992fedfc9ce61561c88056de3c18cffd
tree94093d962b24b3d2b9a8c6800ff80dbb5fec0829
parent7b1a70023127666e98a1fc7f7a3ee04f7bdc4028
gh-134152: Fix UnboundLocalError in email._header_value_parser _get_ptext_to_endchars (#134233)

Fix an UnboundLocalError that can occur when parsing certain delimited constructs in headers (domain literals, quoted strings, comments). After the fix the _get_ptext_to_endchars returns an empty string if there is no content after the opening delimiter. The calling code is responsible for handling the lack of the trailing delimiter, which it already does; this edge case was the header ending immediately after the opening delimiter.
Lib/email/_header_value_parser.py
Lib/test/test_email/test__header_value_parser.py
Misc/NEWS.d/next/Library/2025-05-19-10-32-11.gh-issue-134152.INJC2j.rst [new file with mode: 0644]