summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFolker Bernitt <fbernitt@thoughtworks.com>2015-08-11 13:38:56 +0200
committerFolker Bernitt <fbernitt@thoughtworks.com>2015-08-11 13:38:56 +0200
commitae1a4647f0ab67953cea88eee45fc4d1eabc2dbc (patch)
treeadf9975facf903397631dd7af845b2e714d51361
parent2a58095dcd4168e6d36ac86ea44fd350c24e03d5 (diff)
[bug] Fix typo in content-transfer-encoding in walk.py.
The get_raw_docs method accesses header field content-transfer-encoding using the string 'content-transfer-type' so the raw doc dict always ends up with that value set to empty string.
-rw-r--r--mail/src/leap/mail/adaptors/tests/test_soledad_adaptor.py14
-rw-r--r--mail/src/leap/mail/walk.py2
2 files changed, 15 insertions, 1 deletions
diff --git a/mail/src/leap/mail/adaptors/tests/test_soledad_adaptor.py b/mail/src/leap/mail/adaptors/tests/test_soledad_adaptor.py
index bdc2c48f..0ddea30c 100644
--- a/mail/src/leap/mail/adaptors/tests/test_soledad_adaptor.py
+++ b/mail/src/leap/mail/adaptors/tests/test_soledad_adaptor.py
@@ -28,6 +28,9 @@ from leap.mail.adaptors.soledad import SoledadIndexMixin
from leap.mail.adaptors.soledad import SoledadMailAdaptor
from leap.mail.tests.common import SoledadTestMixin
+from email.MIMEMultipart import MIMEMultipart
+from email.mime.text import MIMEText
+
# DEBUG
# import logging
# logging.basicConfig(level=logging.DEBUG)
@@ -330,6 +333,17 @@ class SoledadMailAdaptorTestCase(SoledadTestMixin):
self.assertEqual(msg.wrapper.hdoc.subject, subject)
self.assertEqual(msg.wrapper.cdocs[1].phash, phash)
+ def test_get_msg_from_string_multipart(self):
+ msg = MIMEMultipart()
+ msg['Subject'] = 'Test multipart mail'
+ msg.attach(MIMEText(u'a utf8 message', _charset='utf-8'))
+ adaptor = self.get_adaptor()
+
+ msg = adaptor.get_msg_from_string(TestMessageClass, msg.as_string())
+
+ self.assertEqual('base64', msg.wrapper.cdocs[1].content_transfer_encoding)
+ self.assertEqual('YSB1dGY4IG1lc3NhZ2U=\n', msg.wrapper.cdocs[1].raw)
+
def test_get_msg_from_docs(self):
adaptor = self.get_adaptor()
mdoc = dict(
diff --git a/mail/src/leap/mail/walk.py b/mail/src/leap/mail/walk.py
index f6133094..1c74366a 100644
--- a/mail/src/leap/mail/walk.py
+++ b/mail/src/leap/mail/walk.py
@@ -99,7 +99,7 @@ def get_raw_docs(msg, parts):
"content-type": headers.get(
'content-type', ''),
"content-transfer-encoding": headers.get(
- 'content-transfer-type', '')
+ 'content-transfer-encoding', '')
} for payload, headers in get_payloads(msg)
if not isinstance(payload, list))