From 1d07ef401ec16580360252ebe0bf218e979f7513 Mon Sep 17 00:00:00 2001 From: Rob Wu Date: Sun, 2 Jul 2023 15:28:33 +0200 Subject: [PATCH] [CRX] Re-initialize initialBookmark after URL rewrite `PDFViewerApplication` reads from `location.hash` to initialize `initialBookmark`. But when extensions/chromium/pdfHandler.js prepares the redirect URL, the reference fragment is encoded instead of bare. `rewriteUrlClosure` in `chromecom.js` is responsible for decoding the URL, but that currently runs too late. To fix this, update `initialBookmark` after rewriting the URL. This was not a problem in the past because `rewriteUrlClosure` in `chromecom.js` executed before the initialization of `initialBookmark`. --- web/chromecom.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/web/chromecom.js b/web/chromecom.js index 581be863e..985ba9ca2 100644 --- a/web/chromecom.js +++ b/web/chromecom.js @@ -42,6 +42,9 @@ if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("CHROME")) { } AppOptions.set("defaultUrl", defaultUrl); + // Ensure that PDFViewerApplication.initialBookmark reflects the current hash, + // in case the URL rewrite above results in a different hash. + PDFViewerApplication.initialBookmark = location.hash.slice(1); })(); const ChromeCom = {