@@ -3011,14 +3011,6 @@ def _fold_as_ew(to_encode, lines, maxlen, last_ew, ew_combine_allowed, charset,
30113011 to_encode = str (
30123012 get_unstructured (lines [- 1 ][last_ew :] + to_encode ))
30133013 lines [- 1 ] = lines [- 1 ][:last_ew ]
3014- elif to_encode [0 ] in WSP and not last_word_is_ew :
3015- # We're joining this to non-encoded text, so don't encode
3016- # the leading blank.
3017- leading_wsp = to_encode [0 ]
3018- to_encode = to_encode [1 :]
3019- if (len (lines [- 1 ]) == maxlen ):
3020- lines .append (_steal_trailing_WSP_if_exists (lines ))
3021- lines [- 1 ] += leading_wsp
30223014 elif last_word_is_ew :
30233015 # If we are following up an encoded word with another encoded word,
30243016 # any white space between the two will be ignored when decoded.
@@ -3029,6 +3021,14 @@ def _fold_as_ew(to_encode, lines, maxlen, last_ew, ew_combine_allowed, charset,
30293021 lines [- 1 ] = (lines [- 1 ][:len_without_wsp ]
30303022 + (' ' if leading_whitespace else '' ))
30313023 to_encode = leading_whitespace + to_encode
3024+ elif to_encode [0 ] in WSP :
3025+ # We're joining this to non-encoded text, so don't encode
3026+ # the leading blank.
3027+ leading_wsp = to_encode [0 ]
3028+ to_encode = to_encode [1 :]
3029+ if (len (lines [- 1 ]) == maxlen ):
3030+ lines .append (_steal_trailing_WSP_if_exists (lines ))
3031+ lines [- 1 ] += leading_wsp
30323032
30333033 trailing_wsp = ''
30343034 if to_encode [- 1 ] in WSP :
0 commit comments