Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Allow foriegn origin URLs only for hosted viewers. #6916
Currently we provide demo viewer source code so web developers can extend and build custom viewers upon it. The "file" parameter is causing confusions among developers due to XHR restrictions such as CORS or passing binary data.
Also, most of the developers don’t want or forget to modify viewer to adapt it to their own use case. The primary use case the PDF.js team considered is hosting generic viewer to view files from different locations.
This patch locks down the "file" parameter to be used only for the files located at the same server by default. The main reason for it is to minimize unintended use of viewer host network resources to display somebody else’s documents (e.g. full viewer size might reach up to 2MB) and avoid content spoofing to avoid presenting false information on behalf of the host domain. The exceptions for now are viewers that are hosted at "file:///..." and "http://mozilla.github.io/" locations. If a host's use case matches ours, the validation function/parameters can be adjusted to change that.