diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 373efb6eead..9fd6652da09 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -1370,6 +1370,9 @@ class MailThread(models.AbstractModel): if message.get_content_type() == 'text/plain': # text/plain ->
                 body = tools.append_content_to_html('', body, preserve=True)
+            elif message.get_content_type() == 'text/html':
+                # we only strip_classes here everything else will be done in by html field of mail.message
+                body = tools.html_sanitize(body, sanitize_tags=False, strip_classes=True)
         else:
             alternative = False
             mixed = False
diff --git a/addons/test_mail/data/test_mail_data.py b/addons/test_mail/data/test_mail_data.py
index c823fa60888..c2e6fdb0454 100644
--- a/addons/test_mail/data/test_mail_data.py
+++ b/addons/test_mail/data/test_mail_data.py
@@ -105,6 +105,36 @@ Please call me as soon as possible this afternoon!
 Sylvie
 """
 
+MAIL_TEMPLATE_HTML = """Return-Path: {return_path}
+To: {to}
+cc: {cc}
+Received: by mail1.openerp.com (Postfix, from userid 10002)
+    id 5DF9ABFB2A; Fri, 10 Aug 2012 16:16:39 +0200 (CEST)
+From: {email_from}
+Subject: {subject}
+MIME-Version: 1.0
+Content-Type: text/html; charset=utf-8
+Content-Transfer-Encoding: quoted-printable
+Date: Fri, 10 Aug 2012 14:16:26 +0000
+Message-ID: {msg_id}
+{extra}
+
+
+
+ =20
+  
+ =20
+ =20
+
+  

Please call me as soon as possible this afternoon!

+ +

--
+ Sylvie +

+ + +""" + MAIL_MULTIPART_MIXED = """Return-Path: X-Original-To: raoul@grosbedon.fr Delivered-To: raoul@grosbedon.fr diff --git a/addons/test_mail/tests/test_mail_gateway.py b/addons/test_mail/tests/test_mail_gateway.py index 8c8ab81a3bc..8cfa50aabb9 100644 --- a/addons/test_mail/tests/test_mail_gateway.py +++ b/addons/test_mail/tests/test_mail_gateway.py @@ -44,6 +44,12 @@ class TestEmailParsing(MailCommon): res = self.env['mail.thread'].message_parse(self.from_string(plaintext)) self.assertIn('Please call me as soon as possible this afternoon!', res['body']) + # test pure html + html = self.format(test_mail_data.MAIL_TEMPLATE_HTML, email_from='"Sylvie Lelitre" ') + res = self.env['mail.thread'].message_parse(self.from_string(html)) + self.assertIn('

Please call me as soon as possible this afternoon!

', res['body']) + self.assertNotIn(' html has priority multipart = self.format(MAIL_TEMPLATE, email_from='"Sylvie Lelitre" ') res = self.env['mail.thread'].message_parse(self.from_string(multipart))