summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2021-06-21 14:42:35 +0200
committerAnton Khirnov <anton@khirnov.net>2021-06-21 14:42:35 +0200
commit7aab36b6f9c968627d627e08a67c0ba758460d33 (patch)
tree64e136972441fe59a25a69459e2105b4bd75cc11
parentad0f37016dce17025b310984480ad971721b1e82 (diff)
mail/envelope: fix setting attachment params
Actually pass them as a tuple of tuples. Also, set the charset param only for text attachments.
-rw-r--r--alot/mail/envelope.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/alot/mail/envelope.py b/alot/mail/envelope.py
index 4d388aac..ad5f2ee4 100644
--- a/alot/mail/envelope.py
+++ b/alot/mail/envelope.py
@@ -221,6 +221,8 @@ class Envelope:
ctype = helper.guess_mimetype(data)
+ params = []
+
# accept only valid utf-8 as text attachments
if ctype.partition('/')[0] == 'text':
try:
@@ -228,11 +230,13 @@ class Envelope:
except UnicodeDecodeError as e:
raise ValueError('Attachment is not valid UTF-8') from e
+ params.append(('charset', 'utf-8'))
+
# Set the filename parameter
if not filename:
filename = os.path.basename(path)
- attachment = Attachment(data, ctype, filename, (('charset', 'utf-8')))
+ attachment = Attachment(data, ctype, filename, tuple(params))
self.attach(attachment)
def attach(self, attachment):