From 05884e9fd9a6131eaff6f86b37af8dc7b0a88217 Mon Sep 17 00:00:00 2001
From: drebs <drebs@leap.se>
Date: Thu, 19 Dec 2013 23:13:43 -0200
Subject: Only try to fetch keys for multipart signed or encrypted messages
 when fetching mail (#4671).

---
 src/leap/mail/imap/fetch.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

(limited to 'src/leap/mail/imap')

diff --git a/src/leap/mail/imap/fetch.py b/src/leap/mail/imap/fetch.py
index f69681a..b1c34ba 100644
--- a/src/leap/mail/imap/fetch.py
+++ b/src/leap/mail/imap/fetch.py
@@ -389,7 +389,9 @@ class LeapIncomingMail(object):
         # try to obtain sender public key
         senderPubkey = None
         fromHeader = msg.get('from', None)
-        if fromHeader is not None:
+        if fromHeader is not None \
+                and (msg.get_content_type() == 'multipart/encrypted' \
+                     or msg.get_content_type() == 'multipart/signed'):
             _, senderAddress = parseaddr(fromHeader)
             try:
                 senderPubkey = self._keymanager.get_key_from_cache(
-- 
cgit v1.2.3