From 29f6463ed94977ad4ad0c2d3b96456336527d8ca Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Sun, 16 Feb 2020 19:55:05 +0100 Subject: [PATCH] Fix #1149 (Prevent invalid file extensions on Kindle Paperwhite download) --- cps/helper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cps/helper.py b/cps/helper.py index 61058f53..0e1c1fcd 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -798,8 +798,8 @@ def get_download_link(book_id, book_format): file_name = get_valid_filename(file_name) headers = Headers() headers["Content-Type"] = mimetypes.types_map.get('.' + book_format, "application/octet-stream") - headers["Content-Disposition"] = "attachment; filename*=UTF-8''%s.%s" % (quote(file_name.encode('utf-8')), - book_format) + headers["Content-Disposition"] = "attachment; filename=%s.%s; filename*=UTF-8''%s.%s" % ( + quote(file_name.encode('utf-8')), book_format, quote(file_name.encode('utf-8')), book_format) return do_download_file(book, book_format, data, headers) else: abort(404)