Skip to content

Commit 6e67bec

Browse files
committed
bpo-40837: Fix email.utils.encode_rfc2231(string, None, None)
encode_rfc2231() must not change the returned value if no transformation of the input was done. This is also mentioned in the docstring of that function. Actual behavior: encode_rfc2231('foo bar', None, None) 'foo%20bar' Expected behavior: encode_rfc2231('foo bar', None, None) 'foo bar'
1 parent 2f172d8 commit 6e67bec

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Lib/email/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,9 @@ def encode_rfc2231(s, charset=None, language=None):
243243
charset is given but not language, the string is encoded using the empty
244244
string for language.
245245
"""
246-
s = urllib.parse.quote(s, safe='', encoding=charset or 'ascii')
247246
if charset is None and language is None:
248247
return s
248+
s = urllib.parse.quote(s, safe='', encoding=charset or 'ascii')
249249
if language is None:
250250
language = ''
251251
return "%s'%s'%s" % (charset, language, s)

0 commit comments

Comments
 (0)