diff --git a/notebook/nbconvert/handlers.py b/notebook/nbconvert/handlers.py index 8d8792d73..e5614956c 100644 --- a/notebook/nbconvert/handlers.py +++ b/notebook/nbconvert/handlers.py @@ -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: