Fixed problem with note titles being incorrectly set for notes containing multiple sets of <h3></h3> titles.
The solution involved making the regular expression for title parsing non-greedy.
This commit is contained in:
parent
a7ca76f611
commit
e2079bbca8
|
@ -7,7 +7,7 @@ class Note( Persistent ):
|
|||
"""
|
||||
An single textual wiki note.
|
||||
"""
|
||||
TITLE_PATTERN = re.compile( u"<h3>(.*)</h3>", flags = re.IGNORECASE )
|
||||
TITLE_PATTERN = re.compile( u"<h3>(.*?)</h3>", flags = re.IGNORECASE )
|
||||
|
||||
def __setstate__( self, state ):
|
||||
if "_Note__deleted_from" not in state:
|
||||
|
|
|
@ -29,11 +29,25 @@ class Test_note( object ):
|
|||
|
||||
def test_set_contents_with_html_title( self ):
|
||||
new_title = u"new title"
|
||||
new_contents = u"<h3>%s<br/></h3>new blah" % new_title
|
||||
new_contents = u"<h3>new<br /> title</h3>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"<h3>new<br /> title</h3>new blah<h3>other title</h3>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
|
||||
|
|
Reference in New Issue