Skip to content

Commit

Permalink
Update Lib/email/_header_value_parser.py
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiy-storchaka authored Jul 30, 2024
1 parent eb43fe4 commit f793b96
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Lib/email/_header_value_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2804,13 +2804,13 @@ def _refold_parse_tree(parse_tree, *, policy):
wrap_as_ew_blocked -= 1
continue
tstr = str(part)
if part.token_type == 'ptext':
# Encode if tstr contains special characters.
if not SPECIALSNL.isdisjoint(tstr):
want_encoding = True
elif not NLSET.isdisjoint(tstr):
# Encode if tstr contains newlines.
want_encoding = True
if not want_encoding:
if part.token_type == 'ptext':
# Encode if tstr contains special characters.
want_encoding = not SPECIALSNL.isdisjoint(tstr)
else:
# Encode if tstr contains newlines.
want_encoding = not NLSET.isdisjoint(tstr)
try:
tstr.encode(encoding)
charset = encoding
Expand Down

0 comments on commit f793b96

Please sign in to comment.