|
|
@ -1332,6 +1332,37 @@ window.PDFView = PDFViewerApplication; // obsolete name, using it as an alias |
|
|
|
//})();
|
|
|
|
//})();
|
|
|
|
//#endif
|
|
|
|
//#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//#if GENERIC
|
|
|
|
|
|
|
|
var HOSTED_VIEWER_ORIGINS = ['null', |
|
|
|
|
|
|
|
'http://mozilla.github.io', 'https://mozilla.github.io']; |
|
|
|
|
|
|
|
function validateFileURL(file) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
var viewerOrigin = new URL(window.location.href).origin || 'null'; |
|
|
|
|
|
|
|
if (HOSTED_VIEWER_ORIGINS.indexOf(viewerOrigin) >= 0) { |
|
|
|
|
|
|
|
// Hosted or local viewer, allow for any file locations
|
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var 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 (e) { |
|
|
|
|
|
|
|
var message = e && e.message; |
|
|
|
|
|
|
|
var loadingErrorMessage = mozL10n.get('loading_error', null, |
|
|
|
|
|
|
|
'An error occurred while loading the PDF.'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var moreInfo = { |
|
|
|
|
|
|
|
message: message |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
PDFViewerApplication.error(loadingErrorMessage, moreInfo); |
|
|
|
|
|
|
|
throw e; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//#endif
|
|
|
|
|
|
|
|
|
|
|
|
function webViewerLoad(evt) { |
|
|
|
function webViewerLoad(evt) { |
|
|
|
//#if !PRODUCTION
|
|
|
|
//#if !PRODUCTION
|
|
|
|
require.config({paths: {'pdfjs': '../src'}}); |
|
|
|
require.config({paths: {'pdfjs': '../src'}}); |
|
|
@ -1351,6 +1382,7 @@ function webViewerInitialized() { |
|
|
|
var queryString = document.location.search.substring(1); |
|
|
|
var queryString = document.location.search.substring(1); |
|
|
|
var params = parseQueryString(queryString); |
|
|
|
var params = parseQueryString(queryString); |
|
|
|
var file = 'file' in params ? params.file : DEFAULT_URL; |
|
|
|
var file = 'file' in params ? params.file : DEFAULT_URL; |
|
|
|
|
|
|
|
validateFileURL(file); |
|
|
|
//#endif
|
|
|
|
//#endif
|
|
|
|
//#if (FIREFOX || MOZCENTRAL)
|
|
|
|
//#if (FIREFOX || MOZCENTRAL)
|
|
|
|
//var file = window.location.href.split('#')[0];
|
|
|
|
//var file = window.location.href.split('#')[0];
|
|
|
|