diff options
-rw-r--r-- | src/leap/mail/__init__.py | 7 | ||||
-rw-r--r-- | src/leap/mail/imap/fetch.py | 25 | ||||
-rw-r--r-- | src/leap/mail/smtp/smtprelay.py | 4 |
3 files changed, 26 insertions, 10 deletions
diff --git a/src/leap/mail/__init__.py b/src/leap/mail/__init__.py index 04a9951..5f4810c 100644 --- a/src/leap/mail/__init__.py +++ b/src/leap/mail/__init__.py @@ -21,8 +21,9 @@ Provide function for loading tests. """ -import unittest +# Do not force the unittest dependency +# import unittest -def load_tests(): - return unittest.defaultTestLoader.discover('./src/leap/mail') +# def load_tests(): +# return unittest.defaultTestLoader.discover('./src/leap/mail') 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,)) diff --git a/src/leap/mail/smtp/smtprelay.py b/src/leap/mail/smtp/smtprelay.py index 5211d8e..5f73be7 100644 --- a/src/leap/mail/smtp/smtprelay.py +++ b/src/leap/mail/smtp/smtprelay.py @@ -82,9 +82,9 @@ def assert_config_structure(config): leap_assert(PORT_KEY in config) leap_assert_type(config[PORT_KEY], int) leap_assert(CERT_KEY in config) - leap_assert_type(config[CERT_KEY], str) + leap_assert_type(config[CERT_KEY], (str, unicode)) leap_assert(KEY_KEY in config) - leap_assert_type(config[KEY_KEY], str) + leap_assert_type(config[KEY_KEY], (str, unicode)) leap_assert(ENCRYPTED_ONLY_KEY in config) leap_assert_type(config[ENCRYPTED_ONLY_KEY], bool) # assert received params are not empty |