Skip to content

pdf 添加跨域功能 修复pdf 页码和高亮没启用bug#746

Open
gaoxingzaq wants to merge 5 commits intokekingcn:masterfrom
gaoxingzaq:pdfjs2
Open

pdf 添加跨域功能 修复pdf 页码和高亮没启用bug#746
gaoxingzaq wants to merge 5 commits intokekingcn:masterfrom
gaoxingzaq:pdfjs2

Conversation

@gaoxingzaq
Copy link
Copy Markdown
Contributor

No description provided.

});
throw ex;
};
var validateFileURL = function (file) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里把 pdf.js 的同源校验整体去掉了,但 kkFileView 自己其实已经有跨域代理路径:pdf.ftl 会把非本地 URL 改写到 /getCorsFile,后端入口在 OnlinePreviewController#getCorsFile。也就是说这次需求更像是修 kkFileView 的预览入口,而不是全局放开 vendored viewer.html 的跨域限制。现在这个改法会扩大直接访问 /pdfjs/web/viewer.html 时的行为面,而且后续同步 pdf.js 版本也更难维护。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这块是为了配合 ${kkagent} 如果接入服务器支持了 跨域功能 就跳过KK反代

Comment thread server/src/main/resources/web/pdf.ftl Outdated
viewerUrl += "&disabledownload=${pdfDownloadDisable}";
viewerUrl += "&disablebookmark=${pdfBookmarkDisable}";
viewerUrl += "&disableediting=${pdfDisableEditing}";
viewerUrl += "&pdfhighlightall=${highlightall}";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里把 highlightall / watermarkTxt 直接拼进 query string,没有做 encodeURIComponent。这两个值来自请求参数,当前上游只做了 HTML escape;一旦用户传入 &#= 之类字符,viewer URL 就会被截断或解析错位,page/pagemode 这类后续参数也会受到影响。这个路径要么逐项 URL 编码,要么统一用参数对象构造查询串。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants