Skip to content

Commit

Permalink
Merge pull request mozilla#17153 from Snuffleupagus/src-navigator-checks
Browse files Browse the repository at this point in the history
Guard `navigator`-object accesses in `src/`-files (issue 15728)
  • Loading branch information
timvandermeij authored Oct 29, 2023
2 parents 355bce2 + c1fef7d commit 0329b5e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/display/font_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ class FontLoader {
supported = true;
} else if (
typeof navigator !== "undefined" &&
typeof navigator?.userAgent === "string" &&
// User agent string sniffing is bad, but there is no reliable way to
// tell if the font is fully loaded and ready to be used with canvas.
/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent)
Expand Down
13 changes: 7 additions & 6 deletions src/shared/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -616,14 +616,15 @@ class FeatureTest {

static get platform() {
if (
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
typeof navigator === "undefined"
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
(typeof navigator !== "undefined" &&
typeof navigator?.platform === "string")
) {
return shadow(this, "platform", { isMac: false });
return shadow(this, "platform", {
isMac: navigator.platform.includes("Mac"),
});
}
return shadow(this, "platform", {
isMac: navigator.platform.includes("Mac"),
});
return shadow(this, "platform", { isMac: false });
}

static get isCSSRoundSupported() {
Expand Down

0 comments on commit 0329b5e

Please sign in to comment.