summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorPatrick Maia and Victor Shyba <pixelated-team+pmaia+vshyba@thoughtworks.com>2014-11-21 19:07:27 -0300
committerPatrick Maia <pmaia@thoughtworks.com>2014-11-21 19:07:27 -0300
commit5c39786d9166d4882e787d6b80d7086c5c34e395 (patch)
tree6c114ca223c03c010e75ed46a0653c0a68951e67 /service
parent5f39512edef09f1a6c88e73c170880761b096ba6 (diff)
for #14, properly split and strip addresses
Diffstat (limited to 'service')
-rw-r--r--service/pixelated/adapter/mail.py3
-rw-r--r--service/test/unit/adapter/mail_test.py14
2 files changed, 16 insertions, 1 deletions
diff --git a/service/pixelated/adapter/mail.py b/service/pixelated/adapter/mail.py
index 5977e252..fc32366a 100644
--- a/service/pixelated/adapter/mail.py
+++ b/service/pixelated/adapter/mail.py
@@ -225,7 +225,8 @@ class PixelatedMail(Mail):
header_value = self.hdoc.content['headers'].get(header)
if not header_value:
continue
- _headers[header] = header_value if type(header_value) is list else header_value.split(', ')
+ _headers[header] = header_value if type(header_value) is list else header_value.split(',')
+ _headers[header] = map(lambda x: x.strip(), _headers[header])
for header in ['From', 'Subject']:
_headers[header] = self.hdoc.content['headers'].get(header)
diff --git a/service/test/unit/adapter/mail_test.py b/service/test/unit/adapter/mail_test.py
index d0e2bcec..eaa6efb4 100644
--- a/service/test/unit/adapter/mail_test.py
+++ b/service/test/unit/adapter/mail_test.py
@@ -112,6 +112,20 @@ class TestPixelatedMail(unittest.TestCase):
self.assertRegexpMatches(mail.body, '([\s\S]*100%){2}')
+ def test_clean_line_breaks_on_address_headers(self):
+ fdoc, hdoc, bdoc = test_helper.leap_mail(flags=['\\Recent'])
+ hdoc.content['headers']['To'] = 'One <one@mail.com>,\nTwo <two@mail.com>, Normal <normal@mail.com>,\nalone@mail.com'
+ hdoc.content['headers']['Bcc'] = hdoc.content['headers']['To']
+ hdoc.content['headers']['Cc'] = hdoc.content['headers']['To']
+
+ mail = PixelatedMail.from_soledad(fdoc, hdoc, bdoc, soledad_querier=self.querier)
+
+ for header_label in ['To', 'Cc', 'Bcc']:
+ for address in mail.headers[header_label]:
+ self.assertNotIn('\n', address)
+ self.assertNotIn(',', address)
+ self.assertEquals(4, len(mail.headers[header_label]))
+
class InputMailTest(unittest.TestCase):
mail_dict = lambda x: {