summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/leap/bitmask/mail/incoming/service.py6
-rw-r--r--tests/integration/mail/incoming/test_incoming_mail.py21
2 files changed, 27 insertions, 0 deletions
diff --git a/src/leap/bitmask/mail/incoming/service.py b/src/leap/bitmask/mail/incoming/service.py
index a68adc2..504fd7e 100644
--- a/src/leap/bitmask/mail/incoming/service.py
+++ b/src/leap/bitmask/mail/incoming/service.py
@@ -429,6 +429,7 @@ class IncomingMail(Service):
# parse the original message
encoding = get_email_charset(data)
msg = self._parser.parsestr(data)
+ self._strip_leap_headers(msg)
fromHeader = msg.get('from', None)
senderAddress = None
@@ -461,6 +462,11 @@ class IncomingMail(Service):
d.addCallback(add_leap_header)
return d
+ def _strip_leap_headers(self, msg):
+ for h in [self.LEAP_ENCRYPTION_HEADER, self.LEAP_SIGNATURE_HEADER]:
+ if h in msg:
+ del msg[h]
+
def _decrypt_by_content_type(self, msg, senderAddress, encoding):
if msg.get_content_type() == MULTIPART_ENCRYPTED:
d = self._decrypt_multipart_encrypted_msg(msg, senderAddress)
diff --git a/tests/integration/mail/incoming/test_incoming_mail.py b/tests/integration/mail/incoming/test_incoming_mail.py
index 3dc7ca7..0deee65 100644
--- a/tests/integration/mail/incoming/test_incoming_mail.py
+++ b/tests/integration/mail/incoming/test_incoming_mail.py
@@ -287,6 +287,27 @@ subject: independence of cyberspace
self.assertEquals(msg.headers['X-Leap-Encryption'], 'decrypted')
+ def testStripLeapHeaders(self):
+ ENC_HEADER = "fake encryption header"
+ SIG_HEADER = "fake signature header"
+
+ message = Parser().parsestr(self.EMAIL)
+ message.add_header("X-Leap-Encryption", ENC_HEADER)
+ message.add_header("X-Leap-Signature", SIG_HEADER)
+ self.fetcher._add_message_locally = Mock()
+
+ def check_headers(_):
+ self.assertTrue(self.fetcher._add_message_locally.called,
+ "The message was not added to soledad")
+ _, data = self.fetcher._add_message_locally.call_args[0][0]
+ msg = Parser().parsestr(data)
+ self.assertNotEqual(msg.get('X-Leap-Encryption', ''), ENC_HEADER)
+ self.assertNotEqual(msg.get('X-Leap-Signature', ''), SIG_HEADER)
+
+ d = self._do_fetch(message.as_string())
+ d.addCallback(check_headers)
+ return d
+
def testDecryptEmail(self):
self.fetcher._decryption_error = Mock()