diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2018-04-24 09:16:39 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2018-04-24 09:16:39 -0700 |
commit | bd7a5051e4aefb8ad1a8eea7f7b477d4038fd7de (patch) | |
tree | 93fac852ea1a23b3e4cc156eebb9b7e9bc5ddb21 /alot | |
parent | 3360b12fa4af565d71d851fb4021a8bdbff3fb6d (diff) |
db/utils: handle mail with bogus encodings
I've run into this with misconfigured git-send-email messages, where the
encoding is utf-8, but the declared encoding is true or 8bit.
Diffstat (limited to 'alot')
-rw-r--r-- | alot/db/utils.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/alot/db/utils.py b/alot/db/utils.py index 88e2b0f2..ef51a8b5 100644 --- a/alot/db/utils.py +++ b/alot/db/utils.py @@ -366,6 +366,11 @@ def extract_body(mail, types=None, field_key='copiousoutput'): raw_payload = payload.encode('raw-unicode-escape') try: payload = raw_payload.decode(enc) + except LookupError: + # In this case the email has an unknown encoding, fall back to + # guessing + enc = helper.guess_encoding(raw_payload) + payload = raw_payload.decode(enc) except UnicodeDecodeError: pass elif cte != '7bit': |