8000 gh-121650: Encode newlines in headers, and verify headers are sound by encukou · Pull Request #122233 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-121650: Encode newlines in headers, and verify headers are sound #122233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 30, 2024
Prev Previous commit
Update Lib/email/_header_value_parser.py
  • Loading branch information
serhiy-storchaka authored Jul 30, 2024
commit f793b966f801605e56ff06f6b85eac0b8dd4aeea
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
Loading
0