From 06e4580f8ba83e84f8a39c5a9e18c17ec5f60abf Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 16 Feb 2025 13:55:35 +0100 Subject: [PATCH] Ensure that the `useWorkerFetch` fallback value is always a boolean If either of the factory-urls are missing or invalid, the fallback value would currently become `useWorkerFetch === null`. While that is obviously a falsy value, which means that the code still works as intended, we should ensure that this is consistent. --- src/display/api.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/display/api.js b/src/display/api.js index 38ab1bfe7..944a9b772 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -331,7 +331,8 @@ function getDocument(src = {}) { typeof src.useWorkerFetch === "boolean" ? src.useWorkerFetch : (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) || - (CMapReaderFactory === DOMCMapReaderFactory && + !!( + CMapReaderFactory === DOMCMapReaderFactory && StandardFontDataFactory === DOMStandardFontDataFactory && WasmFactory === DOMWasmFactory && cMapUrl && @@ -339,7 +340,8 @@ function getDocument(src = {}) { wasmUrl && isValidFetchUrl(cMapUrl, document.baseURI) && isValidFetchUrl(standardFontDataUrl, document.baseURI) && - isValidFetchUrl(wasmUrl, document.baseURI)); + isValidFetchUrl(wasmUrl, document.baseURI) + ); // Parameters only intended for development/testing purposes. const styleElement =