diff --git a/openerp/addons/base/tests/test_mail.py b/openerp/addons/base/tests/test_mail.py
index 05457728c80..d4391529d3a 100644
--- a/openerp/addons/base/tests/test_mail.py
+++ b/openerp/addons/base/tests/test_mail.py
@@ -116,13 +116,45 @@ class TestSanitizer(unittest.TestCase):
sanitized,
'html_sanitize escaped valid address-like')
+ def test_style_parsing(self):
+ test_data = [
+ (
+ 'Coin coin ',
+ ['background-color: red', 'Coin coin'],
+ ['position', 'top', 'left']
+ ), (
+ """
youplaboum
""",
+ ['font-size: 30px', 'youplaboum'],
+ ['some-property', 'top', 'cheval']
+ ), (
+ 'Coincoin',
+ [],
+ ['width']
+ )
+ ]
+
+ for test, in_lst, out_lst in test_data:
+ new_html = html_sanitize(test, strict=False, strip_style=False, strip_classes=False)
+ for text in in_lst:
+ self.assertIn(text, new_html)
+ for text in out_lst:
+ self.assertNotIn(text, new_html)
+
+ # style should not be sanitized if removed
+ new_html = html_sanitize(test_data[0][0], strict=False, strip_style=True, strip_classes=False)
+ self.assertEqual(new_html, u'Coin coin ')
+
def test_edi_source(self):
html = html_sanitize(test_mail_examples.EDI_LIKE_HTML_SOURCE)
- self.assertIn('div style="font-family: \'Lucida Grande\', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF;', html,
- 'html_sanitize removed valid style attribute')
- self.assertIn('', html,
- 'html_sanitize removed valid style attribute')
- self.assertIn('img class="oe_edi_paypal_button" src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif"', html,
+ self.assertIn(
+ 'font-family: \'Lucida Grande\', Ubuntu, Arial, Verdana, sans-serif;', html,
+ 'html_sanitize removed valid styling')
+ self.assertIn(
+ 'src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif"', html,
'html_sanitize removed valid img')
self.assertNotIn('