Skip to content

Commit

Permalink
Fix DOMFilterFactory.#createUrl in MOZCENTRAL builds (18417 PR foll…
Browse files Browse the repository at this point in the history
…ow-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.
  • Loading branch information
Snuffleupagus committed Jul 15, 2024
1 parent 87e74a7 commit 4c45948
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/display/display_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<base>`-element present, hence a relative URL should work.
this.#baseUrl = "";
} else if (isDataScheme(url)) {
if (this.#baseUrl === undefined) {
// Unless a `<base>`-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) {
Expand Down

0 comments on commit 4c45948

Please sign in to comment.