diff options
Diffstat (limited to 'service')
-rw-r--r-- | service/pixelated/adapter/mail.py | 3 | ||||
-rw-r--r-- | service/test/unit/adapter/mail_test.py | 14 |
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: { |