diff --git a/threaded_messages/tests.py b/threaded_messages/tests.py index 17c7f11..831dd79 100644 --- a/threaded_messages/tests.py +++ b/threaded_messages/tests.py @@ -3,7 +3,7 @@ from django.contrib.auth.models import User from models import Message from utils import strip_quotes - +from django.utils.html import strip_tags class UtilsTest(TestCase): def test_strip_quotes(self): @@ -12,6 +12,14 @@ def test_strip_quotes(self): nyan nyan nyan nyan nyan + + + + + + + + 2011/10/28 Nyan Cat : > hey guys > sarete il 31 dicembre con Pascal a Firenze? @@ -29,13 +37,3 @@ def test_strip_quotes(self): """ self.assertEquals(body_stripped.strip(), strip_quotes(body).strip()) - def test_strip_quotes(self): - body = "miao\r\n\r\n2011/12/13 Fabrizio Sestito :\r\n> try\r\n>\r\n> 2011/12/13 Fabrizio Sestito :\r\n>> repr\r\n>>\r\n>> 2011/12/13 Fabrizio Sestito :\r\n>>> meow\r\n>>>\r\n>>> 2011/12/13 Fabrizio Sestito :\r\n>>>> mhh?\r\n>>>>\r\n>>>>\r\n>>>> 2011/12/13 Fabrizio Sestito :\r\n>>>>> nyancat\r\n>>>>>\r\n>>>>> 2011/12/13 Fabrizio Sestito :\r\n>>>>>> hi there\r\n>>>>>>\r\n>>>>>>\r\n>>>>>> 2011/12/13 Fabrizio Sestito :\r\n>>>>>>> fgfg\r\n>>>>>>>\r\n>>>>>>> 2011/12/13 Fabrizio Sestito :\r\n>>>>>>>> dfdfd\r\n>>>>>>>>\r\n>>>>>>>> On Tue, Dec 13, 2011 at 12:35 PM, Fabrizio Sestito wrote:\r\n>>>>>>>>> ciao\n" - - body_stripped = """miao - - -""" - - self.assertEquals(body_stripped.strip(), strip_quotes(body).strip()) - diff --git a/threaded_messages/utils.py b/threaded_messages/utils.py index 27f684a..71f47f0 100644 --- a/threaded_messages/utils.py +++ b/threaded_messages/utils.py @@ -94,7 +94,12 @@ def strip_quotes(body): if l.lstrip().startswith('>'): if not custom_line_no: custom_line_no = i-1 - lines.pop(custom_line_no) + popme_no = custom_line_no + #import nose; nose.tools.set_trace() + lines.pop(popme_no) + while lines[popme_no] =='\n' and popme_no <= 0: + lines.pop(popme_no) + popme_no -= 1 break stripped_lines = [s for s in lines if not s.lstrip().startswith('>')]