summaryrefslogtreecommitdiff
path: root/alot/db/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'alot/db/utils.py')
-rw-r--r--alot/db/utils.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/alot/db/utils.py b/alot/db/utils.py
index e42deed7..00cf0e44 100644
--- a/alot/db/utils.py
+++ b/alot/db/utils.py
@@ -130,9 +130,9 @@ def message_from_file(handle):
add_signature_headers(m, sigs, malformed)
# handle OpenPGP encrypted data
- elif (m.is_multipart() and
+ elif (m.is_multipart() and m.get_content_subtype() == 'encrypted' and
m.get_payload(0).get_content_type() == 'application/pgp-encrypted' and
- m.get_payload(0).get_payload() == 'Version: 1'):
+ 'Version: 1' in m.get_payload(0).get_payload()):
# RFC 3156 is quite strict:
# * exactly two messages
# * the first is of type 'application/pgp-encrypted'
@@ -141,6 +141,13 @@ def message_from_file(handle):
# * the second contains the encrypted and possibly signed data
malformed = False
+ p = get_params(m)
+
+ want = 'application/pgp-encrypted'
+ if p.get('protocol', 'nothing') != want:
+ malformed = 'expected protocol={0}, got: {1}'.format(
+ want, p.get('protocol', 'nothing'))
+
want = 'application/octet-stream'
ct = m.get_payload(1).get_content_type()
if ct != want: