Skip to content

Commit

Permalink
feat: disable file origin validation
Browse files Browse the repository at this point in the history
  • Loading branch information
usman-bajwa committed Aug 9, 2023
1 parent ae1ec21 commit 51df23f
Showing 1 changed file with 1 addition and 22 deletions.
23 changes: 1 addition & 22 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2237,28 +2237,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
];
// eslint-disable-next-line no-var
var validateFileURL = function (file) {
if (!file) {
return;
}
try {
const viewerOrigin = new URL(window.location.href).origin || "null";
if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
// Hosted or local viewer, allow for any file locations
return;
}
const fileOrigin = new URL(file, window.location.href).origin;
// Removing of the following line will not guarantee that the viewer will
// start accepting URLs from foreign origin -- CORS headers on the remote
// server must be properly configured.
if (fileOrigin !== viewerOrigin) {
throw new Error("file origin does not match viewer's");
}
} catch (ex) {
PDFViewerApplication.l10n.get("loading_error").then(msg => {
PDFViewerApplication._documentError(msg, { message: ex?.message });
});
throw ex;
}
return true;
};
}

Expand Down

0 comments on commit 51df23f

Please sign in to comment.