Skip to content

Commit aba9808

Browse files
committed
Do not generate empty encoded-words
Fixes #136052.
1 parent bd928a3 commit aba9808

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Lib/email/_header_value_parser.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3011,7 +3011,10 @@ def _fold_as_ew(to_encode, lines, maxlen, last_ew, ew_combine_allowed, charset,
30113011
to_encode_word = to_encode_word[:-1]
30123012
encoded_word = _ew.encode(to_encode_word, charset=encode_as)
30133013
excess = len(encoded_word) - remaining_space
3014-
lines[-1] += encoded_word
3014+
# If encoding a single character pushes this line over the limit,
3015+
# give up on it and go to the next line.
3016+
if to_encode_word != "":
3017+
lines[-1] += encoded_word
30153018
to_encode = to_encode[len(to_encode_word):]
30163019
leading_whitespace = ''
30173020

0 commit comments

Comments
 (0)