From 99e91e622ee524ed95cb372f21d9e1cc9e08bd3d Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sat, 10 Jan 2026 12:53:16 +0100 Subject: [PATCH] Change quoting of downloaded filename --- cps/helper.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cps/helper.py b/cps/helper.py index 3d7121659..8cd7b4518 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -1091,14 +1091,12 @@ def get_download_link(book_id, book_format, client): file_name = book.title if len(book.authors) > 0: file_name = file_name + ' - ' + book.authors[0].name - if client == "kindle": - file_name = get_valid_filename(file_name, replace_whitespace=False, force_unidecode=True) - else: - file_name = quote(get_valid_filename(file_name, replace_whitespace=False)) + file_name = get_valid_filename(file_name, replace_whitespace=False, force_unidecode=True) + quoted_file_name = file_name if client == "kindle" else quote(file_name) headers = Headers() headers["Content-Type"] = mimetypes.types_map.get('.' + book_format, "application/octet-stream") headers["Content-Disposition"] = ('attachment; filename="{}.{}"; filename*=UTF-8\'\'{}.{}').format( - file_name, book_format, file_name, book_format) + file_name, book_format, quoted_file_name, book_format) return do_download_file(book, book_format, client, data1, headers) else: log.error("Book id {} not found for downloading".format(book_id))