diff options
author | Fábio Pio <fpio@thoughtworks.com> | 2014-12-17 14:07:42 -0200 |
---|---|---|
committer | Fábio Pio <fpio@thoughtworks.com> | 2014-12-17 14:10:51 -0200 |
commit | 8d71694e252aa517a696403327dae594b43744c0 (patch) | |
tree | c649cb312fc61a82b8eaf045f5912411298a2bc3 /service | |
parent | 200ad7d4a5b5f39717c81eb6a9ad3844044b037c (diff) |
Fixed #199 base64 detection won't break plain text
Body will always return unicode now
Diffstat (limited to 'service')
-rw-r--r-- | service/pixelated/adapter/mail.py | 4 | ||||
-rw-r--r-- | service/test/unit/adapter/mail_test.py | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/service/pixelated/adapter/mail.py b/service/pixelated/adapter/mail.py index 847773b7..b6b566bb 100644 --- a/service/pixelated/adapter/mail.py +++ b/service/pixelated/adapter/mail.py @@ -211,8 +211,8 @@ class PixelatedMail(Mail): body += '--' + self.boundary + '--' return body else: - if self.parts and self.parts['alternatives'][0]['headers']['Content-Transfer-Encoding'] == 'base64': - return base64.b64decode(self.parts['alternatives'][0]['content']) + if self.parts and self.parts['alternatives'][0]['headers'].get('Content-Transfer-Encoding', '') == 'base64': + return unicode(base64.b64decode(self.parts['alternatives'][0]['content']), 'utf-8') else: return self.bdoc.content['raw'] diff --git a/service/test/unit/adapter/mail_test.py b/service/test/unit/adapter/mail_test.py index 5c83bd03..13eef91e 100644 --- a/service/test/unit/adapter/mail_test.py +++ b/service/test/unit/adapter/mail_test.py @@ -171,8 +171,8 @@ class TestPixelatedMail(unittest.TestCase): mail.raw def test_that_body_understands_base64(self): - body = "bl\xe1" - encoded_body = base64.b64encode(body) + body = u'bl\xe1' + encoded_body = unicode(base64.b64encode(body.encode('utf-8'))) fdoc, hdoc, bdoc = test_helper.leap_mail() parts = {'alternatives': []} |