encode file name in Content-Disposition when it contains non-ascii characters

pull/1353/head
wenjun.swj 10 years ago
parent 7a24d5fe58
commit 6684b76ab8

@ -7,7 +7,7 @@ import io
import os
import zipfile
from tornado import web
from tornado import web, escape
from ..base.handlers import (
IPythonHandler, FilesRedirectHandler,
@ -38,7 +38,7 @@ def respond_zip(handler, name, output, resources):
# Headers
zip_filename = os.path.splitext(name)[0] + '.zip'
handler.set_header('Content-Disposition',
'attachment; filename="%s"' % zip_filename)
'attachment; filename="%s"' % escape.url_escape(zip_filename))
handler.set_header('Content-Type', 'application/zip')
# Prepare the zip file
@ -112,7 +112,7 @@ class NbconvertFileHandler(IPythonHandler):
if self.get_argument('download', 'false').lower() == 'true':
filename = os.path.splitext(name)[0] + resources['output_extension']
self.set_header('Content-Disposition',
'attachment; filename="%s"' % filename)
'attachment; filename="%s"' % escape.url_escape(filename))
# MIME type
if exporter.output_mimetype:

Loading…
Cancel
Save