diff --git a/controller/Files.py b/controller/Files.py index fe95bf8..d7c5ee4 100644 --- a/controller/Files.py +++ b/controller/Files.py @@ -213,7 +213,7 @@ cherrypy._cpcgifs.FieldStorage = FieldStorage class Files( object ): - FILE_LINK_PATTERN = re.compile( u'[^<]+', re.IGNORECASE ) + FILE_LINK_PATTERN = re.compile( u'[^<]+', re.IGNORECASE ) """ Controller for dealing with uploaded files, corresponding to the "/files" URL. diff --git a/controller/test/Test_files.py b/controller/test/Test_files.py index e3a9d39..3abd2c6 100644 --- a/controller/test/Test_files.py +++ b/controller/test/Test_files.py @@ -1022,6 +1022,33 @@ class Test_files( Test_controller ): assert db_file.filename == self.filename assert Upload_file.exists( self.file_id ) + def test_purge_unused_keep_file_with_quote_filename( self ): + self.login() + + self.http_upload( + "/files/upload?file_id=%s" % self.file_id, + dict( + notebook_id = self.notebook.object_id, + note_id = self.note.object_id, + ), + filename = self.filename, + file_data = self.file_data, + content_type = self.content_type, + session_id = self.session_id, + ) + + self.note.contents = 'file link' % self.file_id + self.database.save( self.note ) + + # the file is linked to from the note's contents, so this should not delete it + cherrypy.root.files.purge_unused( self.note ) + + db_file = self.database.load( File, self.file_id ) + assert db_file + assert db_file.object_id == self.file_id + assert db_file.filename == self.filename + assert Upload_file.exists( self.file_id ) + def test_purge_unused_all_links( self ): self.login()