[FIX] tools.mail: typo causing infinite loop + fix test parameters to actually enter it

bzr revid: odo@openerp.com-20131018085118-9b2ltkpff5c8yzmr
This commit is contained in:
Olivier Dony 2013-10-18 10:51:18 +02:00
parent f0c49f88d0
commit 71f1665b98
2 changed files with 3 additions and 3 deletions

View File

@ -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:

View File

@ -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))