summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2018-02-26 11:53:24 -0800
committerDylan Baker <dylan@pnwbakers.com>2018-03-01 10:34:56 -0800
commit9e1b01c83df7e1aff048b1a341bbba2642bd5ae7 (patch)
treec3047e9e9937fe38c3430eaba4fa7efb833684d8
parentce076b14bc2c221492f3f80e6d5159d627f0eba0 (diff)
fix messages with content transfer encoding in py3k
the change to raw payload makes sense to me, we need to tell it to decode using the content-transfer-encoding, and then transform tat back into a str. the need to join with '' instead of ' ' doesn't.
-rw-r--r--alot/db/utils.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/alot/db/utils.py b/alot/db/utils.py
index 3db171ab..3244be13 100644
--- a/alot/db/utils.py
+++ b/alot/db/utils.py
@@ -352,7 +352,8 @@ def extract_body(mail, types=None, field_key='copiousoutput'):
continue
enc = part.get_content_charset() or 'ascii'
- raw_payload = part.get_payload()
+ raw_payload = part.get_payload(decode=True).decode(enc)
+
if ctype == 'text/plain':
body_parts.append(string_sanitize(raw_payload))
else:
@@ -437,7 +438,7 @@ def decode_header(header, normalize=False):
for v, enc in valuelist:
v = string_decode(v, enc)
decoded_list.append(string_sanitize(v))
- value = u' '.join(decoded_list)
+ value = ''.join(decoded_list)
if normalize:
value = re.sub(r'\n\s+', r' ', value)
return value