Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

移除对 CSP 响应头 'unsafe-inline' 的依赖 #220

Closed
3 tasks done
PaperStrike opened this issue Mar 7, 2021 · 5 comments · Fixed by #226 or #241
Closed
3 tasks done

移除对 CSP 响应头 'unsafe-inline' 的依赖 #220

PaperStrike opened this issue Mar 7, 2021 · 5 comments · Fixed by #226 or #241
Labels
Feature Request New feature or request Solved
Milestone

Comments

@PaperStrike
Copy link
Member

PaperStrike commented Mar 7, 2021

Issue Checklist

  • I am using NexT version 8.0 or later.
  • I have already read the relevant documents of Hexo and NexT.
  • I have already searched for current issues, which does not help me.

Expected behavior

不使用内联样式和内联脚本。

Actual behavior

  • Links to demo site with this issue: (此 issue 不需要)
  • Links to repository or source code of the blog: (此 issue 不需要)
  • Screenshots: (此 issue 不需要)

NexT 生成了一些内联样式和内联脚本,与 CSP 的最佳实践不合

Steps to reproduce the behavior

(此 issue 不需要)

Other Information

以前的 NexT 仓库有相关 issue 讨论,问题一致,但现在问题在新仓库出现,故再开一个 issue。

@PaperStrike PaperStrike added the Feature Request New feature or request label Mar 7, 2021
@welcome
Copy link

welcome bot commented Mar 7, 2021

Thanks for opening this issue, maintainers will get back to you as soon as possible!

@PaperStrike
Copy link
Member Author

PaperStrike commented Mar 9, 2021

“不使用内联样式” 的说法不太准确,只要保证源文件不使用内联样式、内联样式表就行了。

JS 中利用元素的 JS 属性 style 进行的修改是被允许的(style.cssText 除外,原因与后面一致),只有直接更改 HTML 属性 style 的操作会被禁止(如 setAttribute('style', ''))。在我的搜索中并没有发现 NexT 所使用的 JS 有尝试直接改 HTML 属性的行为,所以将内联样式、内联样式表直接独立为文件就可以做到移除 CSP 的 style-src 中对 unsafe-inline 的依赖。

参见 Violation cases | CSP: style-src - HTTP | MDN

@PaperStrike PaperStrike changed the title 支持 CSP 响应头 script-src 'self' 移除对 CSP 响应头 'unsafe-inline' 的依赖 Mar 9, 2021
@stevenjoezhang stevenjoezhang added this to the 8.4.0 milestone Apr 1, 2021
@njzjz
Copy link
Member

njzjz commented Apr 2, 2021

这个issue不应关闭,还有一堆第三方js没有处理。

@PaperStrike
Copy link
Member Author

有道理

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. It is possible issue was solved or at least outdated. Feel free to open new for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Feature Request New feature or request Solved
Projects
None yet
3 participants