diff options
author | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-08-10 14:51:55 +0200 |
---|---|---|
committer | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-08-11 17:00:34 +0200 |
commit | c00e4115f5bd205a0f65224dccd5e889e7cbf3b8 (patch) | |
tree | 971273abc8477b5f67b42242361c9021cf71b5fe /service/pixelated/adapter | |
parent | b8410e1e199a581155566c6c3b9d40dbda32b082 (diff) |
Fixed unit and integration tests.
Diffstat (limited to 'service/pixelated/adapter')
-rw-r--r-- | service/pixelated/adapter/mailstore/leap_mailstore.py | 9 | ||||
-rw-r--r-- | service/pixelated/adapter/search/__init__.py | 6 |
2 files changed, 10 insertions, 5 deletions
diff --git a/service/pixelated/adapter/mailstore/leap_mailstore.py b/service/pixelated/adapter/mailstore/leap_mailstore.py index 8831ae84..a641c35b 100644 --- a/service/pixelated/adapter/mailstore/leap_mailstore.py +++ b/service/pixelated/adapter/mailstore/leap_mailstore.py @@ -13,6 +13,7 @@ # # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see <http://www.gnu.org/licenses/>. +from email.header import decode_header from uuid import uuid4 from leap.mail.adaptors.soledad import SoledadMailAdaptor from twisted.internet import defer @@ -64,9 +65,13 @@ class LeapMail(Mail): @property def raw(self): - result = '' + result = u'' for k, v in self._headers.items(): - result += '%s: %s\n' % (k, v) + content, encoding = decode_header(v)[0] + if encoding: + result += '%s: %s\n' % (k, unicode(content, encoding=encoding)) + else: + result += '%s: %s\n' % (k, v) result += '\n' if self._body: diff --git a/service/pixelated/adapter/search/__init__.py b/service/pixelated/adapter/search/__init__.py index a95055d2..e1ce5e8c 100644 --- a/service/pixelated/adapter/search/__init__.py +++ b/service/pixelated/adapter/search/__init__.py @@ -129,9 +129,9 @@ class SearchEngine(object): 'sender': self._unicode_header_field(header.get('from', '')), 'subject': self._unicode_header_field(header.get('subject', '')), 'date': milliseconds(header.get('date', '')), - 'to': u','.join([h.decode('utf-8') for h in header.get('to', [''])]), - 'cc': u','.join([h.decode('utf-8') for h in header.get('cc', [''])]), - 'bcc': u','.join([h.decode('utf-8') for h in header.get('bcc', [''])]), + 'to': u','.join([h for h in header.get('to', [''])]), + 'cc': u','.join([h for h in header.get('cc', [''])]), + 'bcc': u','.join([h for h in header.get('bcc', [''])]), 'tag': u','.join(unique(tags)), 'bounced': u','.join(bounced), 'body': unicode(mdict['textPlainBody'] if 'textPlainBody' in mdict else mdict['body']), |