From 4c45948bc49b0cd321537c6d8491137024baf58c Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 13 Jul 2024 10:59:38 +0200 Subject: [PATCH] Fix `DOMFilterFactory.#createUrl` in MOZCENTRAL builds (18417 PR follow-up) Somehow I managed to mess up the URL creation relevant to e.g. MOZCENTRAL builds, which is breaking the pending PDF.js update in mozilla-central; sorry about that! To avoid future issues, we'll now always check if absolute filter-URLs are necessary regardless of the build-target. --- src/display/display_utils.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/display/display_utils.js b/src/display/display_utils.js index 30964c9ab..31fd39023 100644 --- a/src/display/display_utils.js +++ b/src/display/display_utils.js @@ -124,22 +124,20 @@ class DOMFilterFactory extends BaseFilterFactory { } #createUrl(id) { - if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) { - if (this.#baseUrl === undefined) { - const url = this.#document.URL; - if (url === this.#document.baseURI) { - // No ``-element present, hence a relative URL should work. - this.#baseUrl = ""; - } else if (isDataScheme(url)) { + if (this.#baseUrl === undefined) { + // Unless a ``-element is present a relative URL should work. + this.#baseUrl = ""; + + const url = this.#document.URL; + if (url !== this.#document.baseURI) { + if (isDataScheme(url)) { warn('#createUrl: ignore "data:"-URL for performance reasons.'); - this.#baseUrl = ""; } else { this.#baseUrl = url.split("#", 1)[0]; } } - return `url(${this.#baseUrl}#${id})`; } - return `url(${id})`; + return `url(${this.#baseUrl}#${id})`; } addFilter(maps) {