-
Notifications
You must be signed in to change notification settings - Fork 85
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
fix: legacy octal escape is not permitted in strict mode #1736
Conversation
演练此拉取请求主要修改了三个文件: 变更
序列图sequenceDiagram
participant Parser
participant JsAst
participant CSSHandler
Parser->>JsAst: 解析 JavaScript 代码
JsAst-->>Parser: 过滤特定语法错误
Parser->>CSSHandler: 处理内联 CSS
CSSHandler->>CSSHandler: 移除 @imports
CSSHandler-->>Parser: 序列化 CSS 代码
对关联问题的评估
可能相关的 PR
建议的审阅者
诗歌
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🔇 Additional comments (1)e2e/fixtures/config.inline_css/expect.js (1)
请确保此处的双反斜杠 Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
WalkthroughThis pull request addresses an issue where legacy octal escapes were not permitted in strict mode. The changes involve modifying the handling of syntax errors to include Changes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
crates/mako/src/ast/js_ast.rs (1)
279-286
: 新增测试test_legacy_octal
提升了对老式八进制转义的覆盖。该测试用于验证在含有老式八进制转义的情况下不会崩溃,符合修复需求。若有可能,可再补充更多使用场景(如更复杂的字符串、模板字符串等)来提升健壮性。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
crates/mako/src/ast/js_ast.rs
(2 hunks)crates/mako/src/build/parse.rs
(1 hunks)e2e/fixtures/config.inline_css/src/a.css
(1 hunks)
🔇 Additional comments (3)
crates/mako/src/build/parse.rs (1)
126-129
: 确保 format!
的占位符顺序与参数传递一致,并检查潜在注入风险。
这里使用 format!
同时填充 deps
与经序列化的 CSS 内容,请确认是否需要对 deps
做额外的转义或校验,以避免可能的注入风险。整体实现逻辑看起来符合内联 CSS 的需求,可以进一步验证在复杂场景下是否符合业务预期。
crates/mako/src/ast/js_ast.rs (1)
79-84
: 注意忽略 SyntaxError::LegacyOctal
可能引发的兼容性影响。
在严格模式下,忽略该错误可以避免解析时的异常,但仍需确认是否会导致其他潜在问题,例如错误的语义被忽略。若业务需要全面禁止此类用法,或考虑后续添加更严格的检查。
e2e/fixtures/config.inline_css/src/a.css (1)
7-10
: 引入 \002F
内容可能影响用户显示习惯。
该新增选择器使用 content: "\002F";
会在元素前插入斜杠。若有多语言或样式定制需求,需确保此符号在各环境下可正确显示,或考虑在必要时灵活调整。
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1736 +/- ##
==========================================
+ Coverage 54.80% 54.82% +0.01%
==========================================
Files 180 180
Lines 18045 18053 +8
==========================================
+ Hits 9890 9897 +7
- Misses 8155 8156 +1 ☔ View full report in Codecov by Sentry. |
Close #1735
Summary by CodeRabbit
新功能
.a:before
,为元素添加伪元素内容。Bug修复