Repository navigation
fix(fileview): EML 邮件正文安全渲染与 HTML 隔离 - #6
Draft
servicememeai wants to merge 1 commit into
Draft
servicememeai wants to merge 1 commit into
servicememeai wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
目的
修复 kkFileView 旧 EML 查看器直接将邮件正文写入 DOM
innerHTML的潜在脚本注入问题。保留现有 MailParser、邮件头和附件下载流程,不引入新的邮件服务或后端 API。变更
static/eml/src/safe-mail-body.js:纯文本通过textContent渲染;HTML 使用最小元素白名单,只保留允许的数据图片,移除脚本、事件处理器、远程图片、可导航链接和表单。sandbox=""iframe,添加default-src 'none'、script-src 'none'、connect-src 'none'等 CSP,禁止外部网络访问。MailPreviewSecurityTests防止以后恢复不安全渲染调用。验证
mvn -B -o -pl server -am '-Dtest=*,!EncodingTests,!ServerMainTests,!ArchiveTraversalSecurityTests' -Dsurefire.failIfNoSpecifiedTests=false test:130/130 通过。node --check与git diff --check通过。注意