summaryrefslogtreecommitdiff
path: root/src/leap/mail/imap/messages.py
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2014-01-28 10:24:04 -0400
committerKali Kaneko <kali@leap.se>2014-01-28 19:38:46 -0400
commitf096368cfbc49caab52811ae50388aae74272a1a (patch)
treecb410ba33e2ed86af4067613b56d03091d739b10 /src/leap/mail/imap/messages.py
parentf5365ae0c2edb8b3e879f876f2f7e42b25f4616a (diff)
fix find_charset rebase
Diffstat (limited to 'src/leap/mail/imap/messages.py')
-rw-r--r--src/leap/mail/imap/messages.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/leap/mail/imap/messages.py b/src/leap/mail/imap/messages.py
index 35c07f5..7617fb8 100644
--- a/src/leap/mail/imap/messages.py
+++ b/src/leap/mail/imap/messages.py
@@ -335,16 +335,18 @@ class LeapMessage(fields, MailParser, MBoxParser):
charset = find_charset(content_type)
logger.debug('got charset from content-type: %s' % charset)
if charset is None:
- # XXX change for find_charset utility
charset = self._get_charset(body)
try:
body = body.encode(charset)
except UnicodeError as exc:
- logger.error("Unicode error {0}".format(exc))
+ logger.error(
+ "Unicode error, using 'replace'. {0!r}".format(exc))
logger.debug("Attempted to encode with: %s" % charset)
try:
body = body.encode(charset, 'replace')
- except UnicodeError as exc:
+
+ # XXX desperate attempt. I've seen things you wouldn't believe
+ except UnicodeError:
try:
body = body.encode('utf-8', 'replace')
except: