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'
This commit is contained in:
parent
2f172d8f15
commit
6e67becb7b
|
@ -243,9 +243,9 @@ def encode_rfc2231(s, charset=None, language=None):
|
|||
charset is given but not language, the string is encoded using the empty
|
||||
string for language.
|
||||
"""
|
||||
s = urllib.parse.quote(s, safe='', encoding=charset or 'ascii')
|
||||
if charset is None and language is None:
|
||||
return s
|
||||
s = urllib.parse.quote(s, safe='', encoding=charset or 'ascii')
|
||||
if language is None:
|
||||
language = ''
|
||||
return "%s'%s'%s" % (charset, language, s)
|
||||
|
|
Loading…
Reference in New Issue