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

update #14

Merged
merged 348 commits into from
Dec 12, 2024
Merged

update #14

merged 348 commits into from
Dec 12, 2024

Conversation

RS-Imagine
Copy link
Owner

尽量按此模板PR内容,或粘贴相关的ISSUE链接。

已知问题

  1. (示例)版本号管理不规范
    • 版本号直接写在环境变量中,容易出错
    • 多处维护版本号,可能不一致

解决方案

  1. (示例)将版本号管理从 .env.local 迁移到 package.json
    • 统一从 package.json 读取版本号
    • 使用 IIFE 优雅处理版本号获取逻辑
    • 保持向后兼容,支持环境变量覆盖

改动收益

  1. (示例)更规范的版本管理
    • 统一从 package.json 读取
    • 保持与 npm 生态一致
    • 减少人为错误

具体改动

  1. (示例)blog.config.js
    • 移除原有的静态版本号配置
    • 在文件末尾添加动态版本号获取逻辑
    • 保持向后兼容,优先使用环境变量
    • 添加错误处理和默认值

测试确认

  • 本地开发环境测试通过
  • 生产环境构建测试通过
  • 版本号正确显示
  • 环境变量配置正常工作

tangly1024 and others added 30 commits September 17, 2024 21:27
…expand

gitbook导航文件夹悬停自动展开
…expand

gitbook 导航文件夹hover-expand适配移动端
…inline-config

Fix/theme starter inline config
tangly1024 and others added 27 commits November 22, 2024 12:45
…optimise

feat: 优化dockerfile,可使包体积从1.1G缩小至200M
if (item.querySelector('figcaption').textContent.trim() === value) {
item.classList.add('active')
if (iframe) {
iframe.setAttribute('src', iframe.getAttribute('data-src'))

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

DOM text
is reinterpreted as HTML without escaping meta-characters.

Copilot Autofix AI 2 months ago

To fix the problem, we need to ensure that the value from the data-src attribute is properly sanitized before being used as the src attribute of an iframe. One way to do this is to use a library like DOMPurify to sanitize the value. This will ensure that any potentially malicious content is removed before it is used.

  • Import the DOMPurify library.
  • Use DOMPurify to sanitize the value of the data-src attribute before setting it as the src attribute of the iframe.
Suggested changeset 2
themes/photo/index.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/themes/photo/index.js b/themes/photo/index.js
--- a/themes/photo/index.js
+++ b/themes/photo/index.js
@@ -34,2 +34,3 @@
 import { Style } from './style'
+import DOMPurify from 'dompurify'
 
@@ -244,3 +245,4 @@
               if (iframe) {
-                iframe.setAttribute('src', iframe.getAttribute('data-src'))
+                const sanitizedSrc = DOMPurify.sanitize(iframe.getAttribute('data-src'))
+                iframe.setAttribute('src', sanitizedSrc)
               }
EOF
@@ -34,2 +34,3 @@
import { Style } from './style'
import DOMPurify from 'dompurify'

@@ -244,3 +245,4 @@
if (iframe) {
iframe.setAttribute('src', iframe.getAttribute('data-src'))
const sanitizedSrc = DOMPurify.sanitize(iframe.getAttribute('data-src'))
iframe.setAttribute('src', sanitizedSrc)
}
package.json
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/package.json b/package.json
--- a/package.json
+++ b/package.json
@@ -45,3 +45,4 @@
     "react-share": "^4.4.1",
-    "react-tweet-embed": "~2.0.0"
+    "react-tweet-embed": "~2.0.0",
+    "dompurify": "^3.2.3"
   },
EOF
@@ -45,3 +45,4 @@
"react-share": "^4.4.1",
"react-tweet-embed": "~2.0.0"
"react-tweet-embed": "~2.0.0",
"dompurify": "^3.2.3"
},
This fix introduces these dependencies
Package Version Security advisories
dompurify (npm) 3.2.3 None
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Copy link

vercel bot commented Dec 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
imagine-blog ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 12, 2024 3:23pm

@RS-Imagine RS-Imagine merged commit 921bf81 into TestForDeploy Dec 12, 2024
11 checks passed
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.

6 participants