diff --git a/openerp/addons/base/tests/test_mail.py b/openerp/addons/base/tests/test_mail.py index 01193de9962..c3559743d89 100644 --- a/openerp/addons/base/tests/test_mail.py +++ b/openerp/addons/base/tests/test_mail.py @@ -342,6 +342,12 @@ class TestCleaner(unittest2.TestCase): for ext in test_mail_examples.BUG_2_OUT: self.assertNotIn(ext, new_html, 'html_email_cleaner did not removed invalid content') + new_html = html_email_clean(test_mail_examples.BUG3, remove=True, shorten=True, max_length=250) + for ext in test_mail_examples.BUG_3_IN: + self.assertIn(ext, new_html, 'html_email_cleaner wrongly removed valid content') + for ext in test_mail_examples.BUG_3_OUT: + self.assertNotIn(ext, new_html, 'html_email_cleaner did not removed invalid content') + def test_90_misc(self): # False boolean for text must return empty string new_html = html_email_clean(False) diff --git a/openerp/addons/base/tests/test_mail_examples.py b/openerp/addons/base/tests/test_mail_examples.py index 0760bd38bf8..48fedca5f00 100644 --- a/openerp/addons/base/tests/test_mail_examples.py +++ b/openerp/addons/base/tests/test_mail_examples.py @@ -1104,3 +1104,72 @@ BUG_2_OUT = [ 'Fwd: TR: OpenERP S.A' 'fait un mois' ] + + +# BUG 20/08/2014: READ MORE NOT APPEARING +BUG3 = """

OpenERP has been upgraded to version 8.0.

+

What's new in this upgrade?

+
+ +
+

Enjoy the new OpenERP Online!

read less
""" + +BUG_3_IN = [ + 'read more', + '...', +] +BUG_3_OUT = [ + 'New kanban view of documents' +] diff --git a/openerp/tools/mail.py b/openerp/tools/mail.py index d6ac1c1cb43..ab546895943 100644 --- a/openerp/tools/mail.py +++ b/openerp/tools/mail.py @@ -386,6 +386,11 @@ def html_email_clean(html, remove=False, shorten=False, max_length=300, expand_o node.set('in_quote', '1') node.set('tail_remove', '1') if node.tag == 'blockquote' or node.get('text_quote') or node.get('text_signature'): + # here no quote_begin because we want to be able to remove some quoted + # text without removing all the remaining context + node.set('in_quote', '1') + if node.getparent() is not None and node.getparent().get('in_quote'): + # inside a block of removed text but not in quote_begin (see above) node.set('in_quote', '1') # shorten: