From ee5d98d5d00495d36099227266af50332da76cd7 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sat, 22 Sep 2018 20:10:57 +0200 Subject: [PATCH] Make sure PDF.js doesn't try to use the Fetch API Closes #4235 --- qutebrowser/browser/pdfjs.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/qutebrowser/browser/pdfjs.py b/qutebrowser/browser/pdfjs.py index ee291d4eb..cfc15a35b 100644 --- a/qutebrowser/browser/pdfjs.py +++ b/qutebrowser/browser/pdfjs.py @@ -56,11 +56,18 @@ def generate_pdfjs_page(filename, url): return jinja.render('no_pdfjs.html', url=url.toDisplayString(), title="PDF.js not found") - viewer = get_pdfjs_res('web/viewer.html').decode('utf-8') + html = get_pdfjs_res('web/viewer.html').decode('utf-8') + script = _generate_pdfjs_script(filename) - html_page = viewer.replace('', - ''.format(script)) - return html_page + html = html.replace('', + ''.format(script)) + # WORKAROUND for the fact that PDF.js tries to use the Fetch API even with + # qute:// URLs. + pdfjs_script = '' + html = html.replace(pdfjs_script, + '\n' + + pdfjs_script) + return html def _generate_pdfjs_script(filename):