diff --git a/odoo/addons/base/tests/test_mail.py b/odoo/addons/base/tests/test_mail.py index e86dbd34fcf..97d6a3fe39c 100644 --- a/odoo/addons/base/tests/test_mail.py +++ b/odoo/addons/base/tests/test_mail.py @@ -119,6 +119,46 @@ class TestSanitizer(BaseCase): for attr in ['javascript']: self.assertNotIn(attr, sanitized_html, 'html_sanitize did not remove enough unwanted attributes') + def test_outlook_mail_sanitize(self): + case = """
+

Here is a test mail

+

 

+

With a break line

+

 

+

 

+

Then two

+

 

+
+
+

From: Mitchell Admin <dummy@example.com> +
+Sent: Monday, November 20, 2023 8:34 AM
+To: test user <dummy@example.com>
+Subject: test (#23)

+
+
""" + + expected = """
+

Here is a test mail

+

 

+

With a break line

+

 

+

 

+

Then two

+

 

+
+
+

From: Mitchell Admin <dummy@example.com> +
+Sent: Monday, November 20, 2023 8:34 AM
+To: test user <dummy@example.com>
+Subject: test (#23)

+
+
""" + + result = html_sanitize(case) + self.assertEqual(result, expected) + def test_sanitize_unescape_emails(self): not_emails = [ '
cat
', diff --git a/odoo/tools/mail.py b/odoo/tools/mail.py index 5b2914ab264..5ec2d133ca0 100644 --- a/odoo/tools/mail.py +++ b/odoo/tools/mail.py @@ -202,6 +202,9 @@ def html_normalize(src, filter_callback=None): try: src = src.replace('--!>', '-->') src = re.sub(r'(|)', '', src) + # On the specific case of Outlook desktop it adds unnecessary '' tags which are parsed + # in '

' which may alter the appearance (eg. spacing) of the mail body + src = re.sub(r'', '', src) doc = html.fromstring(src) except etree.ParserError as e: # HTML comment only string, whitespace only..