diff options
author | Kali Kaneko <kali@leap.se> | 2013-08-09 11:37:44 +0200 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2013-08-09 11:37:44 +0200 |
commit | 2018ed0138067306a580116cbf94792031700e52 (patch) | |
tree | 8e705b7370f016cde4db3466ca1ee7e4288e83b4 /src/leap | |
parent | b17342777c0ab42b513f570aa2cadf45e9625fcb (diff) | |
parent | c739a4ccc6c6aec37b49f1758cd9f43304b7abe9 (diff) |
Merge remote-tracking branch 'chiiph/bug/double_decrypt_incoming' into develop
Diffstat (limited to 'src/leap')
-rw-r--r-- | src/leap/mail/imap/fetch.py | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/leap/mail/imap/fetch.py b/src/leap/mail/imap/fetch.py index f20c996..9b76592 100644 --- a/src/leap/mail/imap/fetch.py +++ b/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,)) |