From 773ddd7a68f5d839163473fb3038c5a13477cab1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 10 Oct 2024 07:37:26 +0530 Subject: [PATCH] Content server: Fix book with non-ASCII filenames not downloading in the Kindle browser when using the /mobile view Amazon cant even get parsing of Content-Disposition right. --- src/calibre/srv/legacy.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/calibre/srv/legacy.py b/src/calibre/srv/legacy.py index 72c6153e4d..30815cc28b 100644 --- a/src/calibre/srv/legacy.py +++ b/src/calibre/srv/legacy.py @@ -282,4 +282,9 @@ def stanza(ctx, rd, rest): def legacy_get(ctx, rd, what, book_id, library_id, filename): # See https://www.mobileread.com/forums/showthread.php?p=3531644 for why # this is needed for Kobo browsers - return get(ctx, rd, what, book_id, library_id) + ua = rd.inheaders.get('User-Agent', '') + is_old_kindle = 'Kindle/3' in ua + ans = get(ctx, rd, what, book_id, library_id) + if is_old_kindle: # Content-Disposition causes downloads to fail when the filename has non-ascii chars in it + rd.outheaders.pop('Content-Disposition', '') + return ans