mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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.
This commit is contained in:
parent
7b1a700231
commit
a32ea45699
3 changed files with 37 additions and 0 deletions
|
@ -1020,6 +1020,8 @@ def _get_ptext_to_endchars(value, endchars):
|
|||
a flag that is True iff there were any quoted printables decoded.
|
||||
|
||||
"""
|
||||
if not value:
|
||||
return '', '', False
|
||||
fragment, *remainder = _wsp_splitter(value, 1)
|
||||
vchars = []
|
||||
escape = False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue