diff --git a/openerp/tests/test_html_sanitize.py b/openerp/tests/test_html_sanitize.py index 90ccc88cc1d..cb46b325144 100755 --- a/openerp/tests/test_html_sanitize.py +++ b/openerp/tests/test_html_sanitize.py @@ -26,11 +26,15 @@ class TestSanitizer(unittest.TestCase): def test_simple(self): x = "yop" self.assertEqual(x, html_sanitize(x)) + + def test_trailing_text(self): + x = 'lala
yop
xxx' + self.assertEqual(x, html_sanitize(x)) - def test_test_case(self): + def test_no_exception(self): html_sanitize(test_case) - def test_crm(self): + def test_unicode(self): html_sanitize("Merci à l'intérêt pour notre produit.nous vous contacterons bientôt. Merci") if __name__ == '__main__': diff --git a/openerp/tools/html_sanitize.py b/openerp/tools/html_sanitize.py index 5164ceb276e..65f17be074f 100644 --- a/openerp/tools/html_sanitize.py +++ b/openerp/tools/html_sanitize.py @@ -1,17 +1,22 @@ -from pyquery import PyQuery as pq +import lxml.html import re def html_sanitize(x): if not x: return x - root = pq("") if type(x) == str: x = unicode(x, "utf8", "replace") - root.html(x) - result = handle_element(root[0]) - new = pq(result) - return new.html() + root = lxml.html.fromstring("