summaryrefslogtreecommitdiff
path: root/alot/db
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2018-08-11 15:27:53 -0700
committerPatrick Totzke <patricktotzke@gmail.com>2018-08-13 09:25:34 +0100
commit536f39b0586e1a117f7d7580ae3609865b76d4f9 (patch)
tree72f10b04cbea0bfa775d163bcbf4b463d004c9d2 /alot/db
parent696bcbefb4e95036259eab2fc876377c97bb9738 (diff)
Don't try to add Content-Disposition header to email that already has one
Currently in db.utils.extract_body we try to add a Content-Disposition header, regardless of whether an email already has one. This isn't actually legal, and individual mime message may only have one C-D. The correction is to replace the header with the modified header if it already exists, and to add a new one only if the message doesn't have one. Note that I haven't actually seen a message that hits the path that would need "add_header", only "replace_header". I have however included it because it would be a behavioral change to not handle that case. Fixes #1297
Diffstat (limited to 'alot/db')
-rw-r--r--alot/db/utils.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/alot/db/utils.py b/alot/db/utils.py
index 4c72bb7a..c883bb42 100644
--- a/alot/db/utils.py
+++ b/alot/db/utils.py
@@ -470,8 +470,11 @@ def extract_body(mail, types=None, field_key='copiousoutput'):
rendered_payload = render_part(part)
if rendered_payload: # handler had output
body_parts.append(string_sanitize(rendered_payload))
- else: # mark as attachment
- part.add_header('Content-Disposition', 'attachment; ' + cd)
+ # mark as attachment
+ elif cd:
+ part.replace_header('Content-Disposition', 'attachment; ' + cd)
+ else:
+ part.add_header('Content-Disposition', 'attachment;')
return u'\n\n'.join(body_parts)