From e845bdbd56e6ce503fcbd2c277b740a44cd5602f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E6=AA=8E?= Date: Sun, 5 Mar 2017 00:28:37 +0800 Subject: [PATCH] Fix attachment filename File attachment should be url encode rather than utf-8 format --- cps/web.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cps/web.py b/cps/web.py index 5687d604..d5bc1882 100755 --- a/cps/web.py +++ b/cps/web.py @@ -1283,7 +1283,7 @@ def get_download_link(book_id, format): response.headers["Content-Type"] = mimetypes.types_map['.' + format] except: pass - response.headers["Content-Disposition"] = "attachment; filename=\"%s.%s\"" % (file_name.encode('utf-8'), format) + response.headers["Content-Disposition"] = "attachment; filename=\"%s.%s\"" % (urllib.quote(file_name.encode('utf-8')), format) return response else: abort(404)