Fixed a bug in which the /files/preview page couldn't display unicode filenames with special characters.
The problem was that the filename was encoded as UTF-8 twice, rather than once.
This commit is contained in:
parent
8d886deffc
commit
6831fe6d89
|
@ -420,7 +420,7 @@ class Files( object ):
|
|||
if not db_file or not self.__users.check_access( user_id, db_file.notebook_id ):
|
||||
raise Access_error()
|
||||
|
||||
filename = db_file.filename.replace( '"', r"\"" ).encode( "utf8" )
|
||||
filename = db_file.filename.replace( '"', r"\"" )
|
||||
|
||||
return dict(
|
||||
file_id = file_id,
|
||||
|
|
|
@ -472,6 +472,30 @@ class Test_files( Test_controller ):
|
|||
assert result[ u"filename" ] == self.filename
|
||||
assert result[ u"quote_filename" ] == False
|
||||
|
||||
def test_preview_with_unicode_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.unicode_filename,
|
||||
file_data = self.IMAGE_DATA,
|
||||
content_type = self.content_type,
|
||||
session_id = self.session_id,
|
||||
)
|
||||
|
||||
result = self.http_get(
|
||||
"/files/preview?file_id=%s" % self.file_id,
|
||||
session_id = self.session_id,
|
||||
)
|
||||
|
||||
assert result[ u"file_id" ] == self.file_id
|
||||
assert result[ u"filename" ] == self.unicode_filename
|
||||
assert result[ u"quote_filename" ] == False
|
||||
|
||||
def test_preview_with_quote_filename_true( self ):
|
||||
self.login()
|
||||
|
||||
|
|
Reference in New Issue