Skip to content

Commit 87913c6

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 0b20bff commit 87913c6

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
@@ -381,9 +381,9 @@ def encode_rfc2231(s, charset=None, language=None):
381381
charset is given but not language, the string is encoded using the empty
382382
string for language.
383383
"""
384-
s = urllib.parse.quote(s, safe='', encoding=charset or 'ascii')
385384
if charset is None and language is None:
386385
return s
386+
s = urllib.parse.quote(s, safe='', encoding=charset or 'ascii')
387387
if language is None:
388388
language = ''
389389
return "%s'%s'%s" % (charset, language, s)

0 commit comments

Comments
 (0)