[FIX] mail: missing spaces in email subjects composed of several encoding
sometimes some blank spaces are lost in subject of some incoming messages There is a bug in `decode_header` in Python < 3.3, which leads to lost some spaces in the email subjects when several encodings are used in this subject. See - Issue: http://bugs.python.org/issue1079 - Fix: https://hg.python.org/cpython/rev/8c03fe231877 Joining the strings returned in the result of `decode_header` solves most cases. Only extreme cases, like having a subject with several different encodings following each other without white spaces between them could lead to have extra spaces in the subject. It won't happen most of the time. Closes #6629
This commit is contained in:
parent
d1c4d16a3a
commit
242e61796b
|
@ -41,6 +41,8 @@ def decode(text):
|
|||
"""Returns unicode() string conversion of the the given encoded smtp header text"""
|
||||
if text:
|
||||
text = decode_header(text.replace('\r', ''))
|
||||
# The joining space will not be needed as of Python 3.3
|
||||
# See https://hg.python.org/cpython/rev/8c03fe231877
|
||||
return ' '.join([tools.ustr(x[0], x[1]) for x in text])
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue