summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2013-05-27 15:19:10 +0200
committerPatrick Totzke <patricktotzke@gmail.com>2013-06-16 21:18:16 +0100
commit365cdc1137cf4746d46b988f5b51b25e131c4e73 (patch)
tree251c28cc9127066b7f95890aab6a6ae66f97d87d
parent08cf72562b6ac73a2ad834dabc985c89a7daa4fe (diff)
Fix detection of OpenPGP encrypted data
Fix detection of OpenPGP encrypted data and also check the 'protocol' parameter. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
-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: