Commit 15bd0353 authored by telami's avatar telami Committed by kl
parent e0b1cd76
...@@ -1886,7 +1886,7 @@ var PDFViewerApplication = { ...@@ -1886,7 +1886,7 @@ var PDFViewerApplication = {
var validateFileURL = void 0; var validateFileURL = void 0;
{ {
var HOSTED_VIEWER_ORIGINS = ['null', 'http://mozilla.github.io', 'https://mozilla.github.io']; var HOSTED_VIEWER_ORIGINS = ['null', 'http://mozilla.github.io', 'https://mozilla.github.io'];
validateFileURL = function validateFileURL(file) { validateFileURL = function validateFileURL(file,base) {
if (file === undefined) { if (file === undefined) {
return file; return file;
} }
...@@ -1897,7 +1897,7 @@ var validateFileURL = void 0; ...@@ -1897,7 +1897,7 @@ var validateFileURL = void 0;
} }
var fileOrigin = new URL(file, window.location.href).origin; var fileOrigin = new URL(file, window.location.href).origin;
if (fileOrigin !== viewerOrigin) { if (fileOrigin !== viewerOrigin) {
return '/getCorsFile?urlPath=' + encodeURIComponent(file); return base.endsWith('/') ? base : '/' + 'getCorsFile?urlPath=' + encodeURIComponent(file);
} }
} catch (ex) { } catch (ex) {
var message = ex && ex.message; var message = ex && ex.message;
...@@ -1931,10 +1931,12 @@ function loadAndEnablePDFBug(enabledTabs) { ...@@ -1931,10 +1931,12 @@ function loadAndEnablePDFBug(enabledTabs) {
function webViewerInitialized() { function webViewerInitialized() {
var appConfig = PDFViewerApplication.appConfig; var appConfig = PDFViewerApplication.appConfig;
var file = void 0; var file = void 0;
var base = void 0;
var queryString = document.location.search.substring(1); var queryString = document.location.search.substring(1);
var params = (0, _ui_utils.parseQueryString)(queryString); var params = (0, _ui_utils.parseQueryString)(queryString);
file = 'file' in params ? params.file : appConfig.defaultUrl; file = 'file' in params ? params.file : appConfig.defaultUrl;
file = validateFileURL(file); base = 'base' in params ? params.base : appConfig.defaultUrl;
file = validateFileURL(file,base);
var waitForBeforeOpening = []; var waitForBeforeOpening = [];
var fileInput = document.createElement('input'); var fileInput = document.createElement('input');
fileInput.id = appConfig.openFileInputName; fileInput.id = appConfig.openFileInputName;
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
</body> </body>
<script type="text/javascript"> <script type="text/javascript">
document.getElementsByTagName('iframe')[0].src = "/pdfjs/web/viewer.html?file="+encodeURIComponent('${finalUrl}'); document.getElementsByTagName('iframe')[0].src = "${baseUrl}pdfjs/web/viewer.html?base=${baseUrl}&file="+encodeURIComponent('${finalUrl}');
document.getElementsByTagName('iframe')[0].height = document.documentElement.clientHeight-10; document.getElementsByTagName('iframe')[0].height = document.documentElement.clientHeight-10;
/** /**
* 页面变化调整高度 * 页面变化调整高度
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment