10000 gh-136052: Do not generate empty encoded-words by chrullrich · Pull Request #136098 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-136052: Do not generate empty encoded-words #136098

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

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Do not generate empty encoded-words
Fixes #136052.
  • Loading branch information
chrullrich committed Jun 29, 2025
commit aba98083e081411dac595976468ff90b7a31ec32
5 changes: 4 additions & 1 deletion Lib/email/_header_value_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3011,7 +3011,10 @@ def _fold_as_ew(to_encode, lines, maxlen, last_ew, ew_combine_allowed, charset,
to_encode_word = to_encode_word[:-1]
encoded_word = _ew.encode(to_encode_word, charset=encode_as)
excess = len(encoded_word) - remaining_space
lines[-1] += encoded_word
# If encoding a single character pushes this line over the limit,
# give up on it and go to the next line.
if to_encode_word != "":
lines[-1] += encoded_word
to_encode = to_encode[len(to_encode_word):]
leading_whitespace = ''

Expand Down
Loading
0