From 71f1665b986f69c64861143c30ee7eecac9eaf07 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Fri, 18 Oct 2013 10:51:18 +0200 Subject: [PATCH] [FIX] tools.mail: typo causing infinite loop + fix test parameters to actually enter it bzr revid: odo@openerp.com-20131018085118-9b2ltkpff5c8yzmr --- openerp/tests/test_mail.py | 2 +- openerp/tools/mail.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openerp/tests/test_mail.py b/openerp/tests/test_mail.py index 55265760627..c8bbc0c862b 100755 --- a/openerp/tests/test_mail.py +++ b/openerp/tests/test_mail.py @@ -230,7 +230,7 @@ class TestCleaner(unittest2.TestCase): for ext in test_mail_examples.BUG_1_OUT: self.assertNotIn(ext, new_html, 'html_email_cleaner did not removed invalid content') - new_html = html_email_clean(test_mail_examples.BUG2, remove=True, shorten=True, max_length=100) + new_html = html_email_clean(test_mail_examples.BUG2, remove=True, shorten=True, max_length=4000) for ext in test_mail_examples.BUG_2_IN: self.assertIn(ext, new_html, 'html_email_cleaner wrongly removed valid content') for ext in test_mail_examples.BUG_2_OUT: diff --git a/openerp/tools/mail.py b/openerp/tools/mail.py index 528140e90dc..b287ded9d6d 100644 --- a/openerp/tools/mail.py +++ b/openerp/tools/mail.py @@ -279,8 +279,8 @@ def html_email_clean(html, remove=False, shorten=False, max_length=300): # 3/ add the truncated text in a new node, next to 'read more' node if shorten and not overlength and cur_char_nbr + len(node.text or '') > max_length: node_to_truncate = node - while node.get('in_quote') and node.getparent(): - node_to_truncate = node.getparent() + while node_to_truncate.get('in_quote') and node_to_truncate.getparent() is not None: + node_to_truncate = node_to_truncate.getparent() overlength = True node_to_truncate.set('truncate', '1') node_to_truncate.set('truncate_position', str(max_length - cur_char_nbr))