Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't block origin-less blob:-URLs in hosted viewer #9505

Merged
merged 1 commit into from
Feb 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1503,11 +1503,14 @@ if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {
// Hosted or local viewer, allow for any file locations
return;
}
let fileOrigin = new URL(file, window.location.href).origin;
let { origin, protocol, } = new URL(file, window.location.href);
// 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) {
// IE10 / IE11 does not include an origin in `blob:`-URLs. So don't block
// any blob:-URL. The browser's same-origin policy will block requests to
// blob:-URLs from other origins, so this is safe.
if (origin !== viewerOrigin && protocol !== 'blob:') {
throw new Error('file origin does not match viewer\'s');
}
} catch (ex) {
Expand Down