diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-05-25 14:34:18 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-05-25 14:34:18 +0200 |
| commit | 37eed7c509fb5846c89ef37046df4b3cab299719 (patch) | |
| tree | f84141132c09ddafa7922375a84d5bf072265d04 /odoo/tools/mail.py | |
| parent | 943075fd94eec2bc61b751e8828e3bd69054b2f8 (diff) | |
| parent | 58e35522468d1d4c0674518f785a32be56d2c1a2 (diff) | |
[MERGE] forward port branch saas-11.2 up to 58e35522468
Diffstat (limited to 'odoo/tools/mail.py')
| -rw-r--r-- | odoo/tools/mail.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/odoo/tools/mail.py b/odoo/tools/mail.py index 31c42ebd8c9..d3291e648fb 100644 --- a/odoo/tools/mail.py +++ b/odoo/tools/mail.py @@ -10,7 +10,7 @@ import socket import threading import time -from email.header import decode_header +from email.header import decode_header, Header from email.utils import getaddresses, formataddr from lxml import etree @@ -521,11 +521,14 @@ def decode_smtp_header(smtp_header): text. email.header decode_header method return a decoded string and its charset for each decoded par of the header. This method unicodes the decoded header and join them in a complete string. """ + if isinstance(smtp_header, Header): + smtp_header = ustr(smtp_header) if smtp_header: text = decode_header(smtp_header.replace('\r', '')) # The joining space will not be needed as of Python 3.3 - # See https://hg.python.org/cpython/rev/8c03fe231877 - return ' '.join([ustr(x[0], x[1]) for x in text]) + # See https://github.com/python/cpython/commit/07ea53cb218812404cdbde820647ce6e4b2d0f8e + sep = ' ' if pycompat.PY2 else '' + return sep.join([ustr(x[0], x[1]) for x in text]) return u'' # was mail_thread.decode_header() |
