diff --git a/controller/Files.py b/controller/Files.py index 1a0c8d4..0c3072f 100644 --- a/controller/Files.py +++ b/controller/Files.py @@ -239,7 +239,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 42b3d0c..4fd5b91 100644 --- a/controller/test/Test_files.py +++ b/controller/test/Test_files.py @@ -2530,6 +2530,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_nofollow( 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_keep_image_file( self ): self.login()