From e2079bbca8e8e2a3a1643bc43b2ab5c81d7b5562 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Tue, 4 Sep 2007 22:01:42 +0000 Subject: [PATCH] Fixed problem with note titles being incorrectly set for notes containing multiple sets of

titles. The solution involved making the regular expression for title parsing non-greedy. --- model/Note.py | 2 +- model/test/Test_note.py | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/model/Note.py b/model/Note.py index d90071c..cfbc989 100644 --- a/model/Note.py +++ b/model/Note.py @@ -7,7 +7,7 @@ class Note( Persistent ): """ An single textual wiki note. """ - TITLE_PATTERN = re.compile( u"

(.*)

", flags = re.IGNORECASE ) + TITLE_PATTERN = re.compile( u"

(.*?)

", flags = re.IGNORECASE ) def __setstate__( self, state ): if "_Note__deleted_from" not in state: diff --git a/model/test/Test_note.py b/model/test/Test_note.py index 9635c0a..b485986 100644 --- a/model/test/Test_note.py +++ b/model/test/Test_note.py @@ -29,11 +29,25 @@ class Test_note( object ): def test_set_contents_with_html_title( self ): new_title = u"new title" - new_contents = u"

%s

new blah" % new_title + new_contents = u"

new
title

new blah" previous_revision = self.note.revision self.note.contents = new_contents + # html should be stripped out of the title + assert self.note.contents == new_contents + assert self.note.title == new_title + assert self.note.deleted_from == None + assert self.note.revision > previous_revision + + def test_set_contents_with_multiple_titles( self ): + new_title = u"new title" + new_contents = u"

new
title

new blah

other title

hmm" + previous_revision = self.note.revision + + self.note.contents = new_contents + + # should only use the first title assert self.note.contents == new_contents assert self.note.title == new_title assert self.note.deleted_from == None