Commit 566c3cbc authored by Jérome Perrin's avatar Jérome Perrin

fix a problem in converting subject from emails with encoded subject.

Also add missing test for encoded emails


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22305 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5b51af4a
......@@ -125,9 +125,11 @@ class EmailDocument(File, TextDocument):
for (name, value) in self._getMessage().items():
for text, encoding in decode_header(value):
if encoding is not None:
result[name] = result.get(name, '') + text.decode(encoding).encode('utf-8')
text = text.decode(encoding).encode('utf-8')
if name in result:
result[name] = '%s %s' % (result[name], text)
else:
result[name] = result.get(name, '') + text
result[name] = text
return result
security.declareProtected(Permissions.AccessContentsInformation, 'getAttachmentInformationList')
......
......@@ -485,16 +485,27 @@ class TestCRMMailIngestion(ERP5TypeTestCase):
self.assertEqual(document.getSourceValue().getTitle(), 'Sender')
self.assertEqual(document.getDestinationValue().getTitle(), 'Me')
def test_encoding(self):
document = self._ingestMail(filename='encoded')
get_transaction().commit()
self.tic()
self.assertEqual(document.getContentInformation().get('To'),
'Me <me@erp5.org>')
self.assertEqual(document.getSourceValue().getTitle(), 'Sender')
self.assertEqual(document.getDestinationValue().getTitle(), 'Me')
self.assertEqual(document.getContentInformation().get('Subject'),
'Test éncödèd email')
self.assertEqual(document.getTitle(), 'Test éncödèd email')
self.assertEqual(document.getTextContent(), 'cöntént\n')
## TODO:
##
## def test_attachements(self):
## event = self._ingestMail('with_attachements')
##
## def test_encoding(self):
## event = self._ingestMail('utf8')
##
class TestCRMMailSend(ERP5TypeTestCase):
"""Test Mail Sending for CRM
......
Date: Mon, 7 Jul 2008 10:17:56 +0200
From: Sender <sender@customer.com>
To: Me <me@erp5.org>
Subject: Test =?utf8?B?w6luY8O2ZMOoZA==?= email
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
c=C3=B6nt=C3=A9nt
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment