summaryrefslogtreecommitdiff
path: root/mail
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2013-08-09 11:37:44 +0200
committerKali Kaneko <kali@leap.se>2013-08-09 11:37:44 +0200
commit9a993d8d320a465d1a2c60c7eda6f8ce484c4a7b (patch)
tree9c8db6223d031e7ce6f0b1b377f8d217694e41b0 /mail
parentf24acd21d073dd9ac5d5aa25775bc4c0a6c25f2d (diff)
parent81c0e145c1664afa1c72468866c1eb9f6429d795 (diff)
Merge remote-tracking branch 'chiiph/bug/double_decrypt_incoming' into develop
Diffstat (limited to 'mail')
-rw-r--r--mail/src/leap/mail/imap/fetch.py25
1 files changed, 20 insertions, 5 deletions
diff --git a/mail/src/leap/mail/imap/fetch.py b/mail/src/leap/mail/imap/fetch.py
index f20c996..9b76592 100644
--- a/mail/src/leap/mail/imap/fetch.py
+++ b/mail/src/leap/mail/imap/fetch.py
@@ -168,8 +168,23 @@ class LeapIncomingMail(object):
return False
logger.debug('got incoming message: %s' % (rawmsg,))
- # add to inbox and delete from soledad
- self._inbox.addMessage(rawmsg, (self.RECENT_FLAG,))
- doc_id = doc.doc_id
- self._soledad.delete_doc(doc)
- log.msg("deleted doc %s from incoming" % doc_id)
+ try:
+ pgp_beg = "-----BEGIN PGP MESSAGE-----"
+ pgp_end = "-----END PGP MESSAGE-----"
+ if pgp_beg in rawmsg:
+ first = rawmsg.find(pgp_beg)
+ last = rawmsg.rfind(pgp_end)
+ pgp_message = rawmsg[first:first+last]
+
+ decrdata = (self._keymanager.decrypt(
+ pgp_message, self._pkey,
+ # XXX get from public method instead
+ passphrase=self._soledad._passphrase))
+ rawmsg = rawmsg.replace(pgp_message, decrdata)
+ # add to inbox and delete from soledad
+ self._inbox.addMessage(rawmsg, (self.RECENT_FLAG,))
+ doc_id = doc.doc_id
+ self._soledad.delete_doc(doc)
+ log.msg("deleted doc %s from incoming" % doc_id)
+ except Exception as e:
+ logger.error("Problem processing incoming mail: %r" % (e,))