From 58b1b50c2e8bd6ad19948b025bc72dd867530487 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E7=B2=BE=E5=8D=8E?= <842761733@qq.com> Date: Tue, 6 Apr 2021 16:44:40 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9Apdf.js=20?= =?UTF-8?q?=E8=B7=A8=E5=9F=9F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/keking/web/filter/FilterConfiguration.java | 2 -- server/src/main/resources/static/pdfjs/web/viewer.js | 8 +++----- server/src/main/resources/web/pdf.ftl | 7 ++++++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/server/src/main/java/cn/keking/web/filter/FilterConfiguration.java b/server/src/main/java/cn/keking/web/filter/FilterConfiguration.java index ba14b6c44..7a7505bd4 100644 --- a/server/src/main/java/cn/keking/web/filter/FilterConfiguration.java +++ b/server/src/main/java/cn/keking/web/filter/FilterConfiguration.java @@ -30,8 +30,6 @@ public FilterRegistrationBean getTrustHostFilter() { Set filterUri = new HashSet<>(); filterUri.add("/onlinePreview"); filterUri.add("/picturesPreview"); - filterUri.add("/getCorsFile"); - filterUri.add("/addTask"); TrustHostFilter filter = new TrustHostFilter(); FilterRegistrationBean registrationBean = new FilterRegistrationBean(); registrationBean.setFilter(filter); diff --git a/server/src/main/resources/static/pdfjs/web/viewer.js b/server/src/main/resources/static/pdfjs/web/viewer.js index 0b610687b..1fef2f580 100644 --- a/server/src/main/resources/static/pdfjs/web/viewer.js +++ b/server/src/main/resources/static/pdfjs/web/viewer.js @@ -2019,7 +2019,7 @@ var validateFileURL; { var HOSTED_VIEWER_ORIGINS = ["null", "http://mozilla.github.io", "https://mozilla.github.io"]; - validateFileURL = function validateFileURL(file, base) { + validateFileURL = function validateFileURL(file) { if (file === undefined) { return; } @@ -2036,7 +2036,7 @@ var validateFileURL; protocol = _ref11.protocol; if (origin !== viewerOrigin && protocol !== "blob:") { - return (base.endsWith('/') ? base : base + '/') + 'getCorsFile?urlPath=' + encodeURIComponent(file); + throw new Error("file origin does not match viewer's"); } } catch (ex) { var message = ex && ex.message; @@ -2089,14 +2089,12 @@ function loadAndEnablePDFBug(enabledTabs) { function webViewerInitialized() { var appConfig = PDFViewerApplication.appConfig; var file; - var base; var disableDownload; var queryString = document.location.search.substring(1); var params = (0, _ui_utils.parseQueryString)(queryString); file = "file" in params ? params.file : _app_options.AppOptions.get("defaultUrl"); - base = 'base' in params ? params.base : appConfig.defaultUrl; disableDownload = 'disabledownload' in params ? params.disabledownload : 'false'; - validateFileURL(file, base); + validateFileURL(file); var fileInput = document.createElement("input"); fileInput.id = appConfig.openFileInputName; fileInput.className = "fileInput"; diff --git a/server/src/main/resources/web/pdf.ftl b/server/src/main/resources/web/pdf.ftl index f192527bf..fa0167e78 100644 --- a/server/src/main/resources/web/pdf.ftl +++ b/server/src/main/resources/web/pdf.ftl @@ -21,7 +21,12 @@