summaryrefslogtreecommitdiff
path: root/alot/db
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2018-08-06 11:16:20 -0700
committerPatrick Totzke <patricktotzke@gmail.com>2018-08-06 20:04:09 +0100
commitcd032bca1c4b062e2ef660e77d438a15d58e891e (patch)
tree7124edc56fcbb5fab256d71e1f6b6c131df4afa0 /alot/db
parentec3e9eab40153efc7d59a779a4073f303d377a9d (diff)
Set the policy for email.message_from_*
Otherwise they default to the Compat32 policy, which isn't want we want, since we end up with a mixture of new and old types. Fixes: #1292
Diffstat (limited to 'alot/db')
-rw-r--r--alot/db/message.py4
-rw-r--r--alot/db/utils.py5
2 files changed, 6 insertions, 3 deletions
diff --git a/alot/db/message.py b/alot/db/message.py
index b53ec6c0..3c860cac 100644
--- a/alot/db/message.py
+++ b/alot/db/message.py
@@ -3,6 +3,7 @@
# For further details see the COPYING file
import email
import email.charset as charset
+import email.policy
import functools
from datetime import datetime
@@ -103,7 +104,8 @@ class Message(object):
with open(path, 'rb') as f:
self._email = utils.decrypted_message_from_bytes(f.read())
except IOError:
- self._email = email.message_from_string(warning)
+ self._email = email.message_from_string(
+ warning, policy=email.policy.SMTP)
return self._email
def get_date(self):
diff --git a/alot/db/utils.py b/alot/db/utils.py
index eda03051..4c72bb7a 100644
--- a/alot/db/utils.py
+++ b/alot/db/utils.py
@@ -209,7 +209,7 @@ def _handle_encrypted(original, message):
if malformed:
msg = u'Malformed OpenPGP message: {0}'.format(malformed)
- content = email.message_from_string(msg)
+ content = email.message_from_string(msg, policy=email.policy.SMTP)
content.set_charset('utf-8')
original.attach(content)
@@ -291,7 +291,8 @@ def decrypted_message_from_bytes(bytestring):
:param bytes bytestring: an email message as raw bytes
"""
- return decrypted_message_from_message(email.message_from_bytes(bytestring))
+ return decrypted_message_from_message(
+ email.message_from_bytes(bytestring, policy=email.policy.SMTP))
def extract_headers(mail, headers=None):