diff --git a/NEWS b/NEWS
index e336493..fa15a72 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,8 @@
+1.5.2:
+ * Leading/trailing spaces in note titles are now ignored when making links
+ to such notes. This means that creating a link titled "my note" to a note
+ called "my note " now works properly.
+
1.5.1: September 28, 2008
* Implemented CSV exporting, so now you can export all of your notes to a
CSV spreadsheet file. This currently doesn't include revision history or
diff --git a/controller/Html_nuker.py b/controller/Html_nuker.py
index 5274bde..7aaa96e 100644
--- a/controller/Html_nuker.py
+++ b/controller/Html_nuker.py
@@ -25,13 +25,17 @@ class Html_nuker( HTMLParser ):
def handle_entityref( self, ref ):
if self.allow_refs:
- self.result.append( "&%s;" % ref )
+ if ref == "nbsp":
+ self.result.append( " " )
+ else:
+ self.result.append( "&%s;" % ref )
else:
self.result.append( {
"amp": "&",
"lt": "<",
"gt": ">",
"quot": '"',
+ "nbsp": " ",
}.get ( ref, "" ) )
def handle_comment( self, comment ):
@@ -60,4 +64,6 @@ class Html_nuker( HTMLParser ):
self.result = []
self.feed( rawstring )
- return u"".join( self.result )
+ result = u"".join( self.result ).strip()
+
+ return result
diff --git a/controller/Notebooks.py b/controller/Notebooks.py
index 53657cd..16a72c1 100644
--- a/controller/Notebooks.py
+++ b/controller/Notebooks.py
@@ -462,7 +462,7 @@ class Notebooks( object ):
return note
# remove all HTML from the contents and also remove the title
- summary = Html_nuker().nuke( note.contents ).strip()
+ summary = Html_nuker().nuke( note.contents )
if note.title and summary.startswith( note.title ):
summary = summary[ len( note.title ) : ]
diff --git a/controller/test/Test_notebooks.py b/controller/test/Test_notebooks.py
index c486f86..33bec8f 100644
--- a/controller/test/Test_notebooks.py
+++ b/controller/test/Test_notebooks.py
@@ -1204,6 +1204,22 @@ class Test_notebooks( Test_controller ):
user = self.database.load( User, self.user.object_id )
assert user.storage_bytes == 0
+ def test_load_note_by_title_with_trailing_whitespace( self ):
+ self.login()
+
+ result = self.http_post( "/notebooks/load_note_by_title/", dict(
+ notebook_id = self.notebook.object_id,
+ note_title = "%s " % self.note.title,
+ ), session_id = self.session_id )
+
+ note = result[ "note" ]
+
+ assert note.object_id == self.note.object_id
+ assert note.title == self.note.title
+ assert note.contents == self.note.contents
+ user = self.database.load( User, self.user.object_id )
+ assert user.storage_bytes == 0
+
def test_load_note_by_title_case_insensitive( self ):
self.login()
@@ -4711,7 +4727,7 @@ class Test_notebooks( Test_controller ):
self.__assert_imported_notebook( expected_notes, result )
- def test_import_csv_html_title( self ):
+ def test_import_csv_html_in_plaintext_title( self ):
self.login()
csv_data = '"label 1","label 2","label 3"\n5,"blah and stuff
",3.3\n"8","whee
","hmm\nfoo"\n3,4,5' @@ -5040,7 +5056,7 @@ class Test_notebooks( Test_controller ): csv_data = '"label 1","label 2","label 3"\n5,"blah and stuff",3.3\n"8","wh ee","hmm\nfoo"\n3,4,5' expected_notes = [ ( "blah and stuff", "3.3" ), # ( title, contents ) - ( "wh ee", "hmm\nfoo" ), + ( "wh ee", "hmm\nfoo" ), ( "4", "5" ), ] @@ -5103,7 +5119,7 @@ class Test_notebooks( Test_controller ): csv_data = '"label 1","label 2","label 3"\n5,"blah and stuff","3.3 "\n"8","whee","hmm\nfoo"\n3,4,5' expected_notes = [ - ( "3.3 ", "3.3 " ), # ( title, contents ) + ( "3.3", "3.3 " ), # ( title, contents ) ( "hmm", "hmm\nfoo" ), ( "5", "5" ), ] diff --git a/model/test/Test_note.py b/model/test/Test_note.py index 3a466cb..f9b8ee1 100644 --- a/model/test/Test_note.py +++ b/model/test/Test_note.py @@ -49,6 +49,60 @@ class Test_note( object ): assert self.note.user_id == self.user_id assert self.note.creation == self.creation + def test_set_contents_with_title_with_trailing_whitespace( self ): + new_title = u"new title" + new_contents = u"