From c09bd5568c42db209476ddd205592716b182e62a Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 27 Jul 2023 16:08:14 +0200 Subject: [PATCH] Tweak the `useWorkerFetch` default value checks (PR 15879 follow-up) Currently we accidentally accept `cMapUrl` and `standardFontDataUrl` parameters that are empty strings or `null`, since e.g. `new URL(null, document.baseURI)` doesn't throw, when validating the `useWorkerFetch` parameter via the `isValidFetchUrl` helper function. Please note that we are currently failing gracefully in this case, as intended, however the warning-messages printed in the console are perhaps less helpful without this patch. --- src/display/api.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/display/api.js b/src/display/api.js index 8ce1cfb36..7fc56fcd9 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -316,6 +316,8 @@ function getDocument(src) { : (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) || (CMapReaderFactory === DOMCMapReaderFactory && StandardFontDataFactory === DOMStandardFontDataFactory && + cMapUrl && + standardFontDataUrl && isValidFetchUrl(cMapUrl, document.baseURI) && isValidFetchUrl(standardFontDataUrl, document.baseURI)); const canvasFactory =