mirror of
https://gitee.com/kekingcn/file-online-preview.git
synced 2025-04-05 17:37:49 +08:00
修复getCorsFile接口未加base64编码(filter中解码异常)
This commit is contained in:
parent
acffcbfe98
commit
dd65564af6
@ -106,6 +106,12 @@ public class OnlinePreviewController {
|
|||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/getCorsFile", method = RequestMethod.GET)
|
@RequestMapping(value = "/getCorsFile", method = RequestMethod.GET)
|
||||||
public void getCorsFile(String urlPath, HttpServletResponse response) {
|
public void getCorsFile(String urlPath, HttpServletResponse response) {
|
||||||
|
try {
|
||||||
|
urlPath = new String(Base64.decodeBase64(urlPath), StandardCharsets.UTF_8);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.error(String.format(BASE64_DECODE_ERROR_MSG, urlPath, ex));
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (urlPath == null || urlPath.toLowerCase().startsWith("file:") || urlPath.toLowerCase().startsWith("file%3") || !urlPath.toLowerCase().startsWith("http")) {
|
if (urlPath == null || urlPath.toLowerCase().startsWith("file:") || urlPath.toLowerCase().startsWith("file%3") || !urlPath.toLowerCase().startsWith("http")) {
|
||||||
logger.info("读取跨域文件异常,可能存在非法访问,urlPath:{}", urlPath);
|
logger.info("读取跨域文件异常,可能存在非法访问,urlPath:{}", urlPath);
|
||||||
return;
|
return;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
var url = '${finalUrl}';
|
var url = '${finalUrl}';
|
||||||
var baseUrl = '${baseUrl}'.endsWith('/') ? '${baseUrl}' : '${baseUrl}' + '/';
|
var baseUrl = '${baseUrl}'.endsWith('/') ? '${baseUrl}' : '${baseUrl}' + '/';
|
||||||
if (!url.startsWith(baseUrl)) {
|
if (!url.startsWith(baseUrl)) {
|
||||||
url = baseUrl + 'getCorsFile?urlPath=' + encodeURIComponent(url);
|
url = baseUrl + 'getCorsFile?urlPath=' + encodeURIComponent(Base64.encode(url));
|
||||||
}
|
}
|
||||||
document.getElementsByTagName('iframe')[0].src = "${baseUrl}pdfjs/web/viewer.html?file=" + encodeURIComponent(url) + "&disablepresentationmode=${pdfPresentationModeDisable}&disableopenfile=${pdfOpenFileDisable}&disableprint=${pdfPrintDisable}&disabledownload=${pdfDownloadDisable}&disablebookmark=${pdfBookmarkDisable}";
|
document.getElementsByTagName('iframe')[0].src = "${baseUrl}pdfjs/web/viewer.html?file=" + encodeURIComponent(url) + "&disablepresentationmode=${pdfPresentationModeDisable}&disableopenfile=${pdfOpenFileDisable}&disableprint=${pdfPrintDisable}&disabledownload=${pdfDownloadDisable}&disablebookmark=${pdfBookmarkDisable}";
|
||||||
document.getElementsByTagName('iframe')[0].height = document.documentElement.clientHeight - 10;
|
document.getElementsByTagName('iframe')[0].height = document.documentElement.clientHeight - 10;
|
||||||
@ -52,4 +52,4 @@
|
|||||||
initWaterMark();
|
initWaterMark();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user