Conversation
xuewenjie123
commented
May 19, 2025


|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
|
||
| // 关系箭头指向错误 | ||
| { | ||
| wrong: /-->/g, |
Check failure
Code scanning / CodeQL
Bad HTML filtering regexp High
Copilot Autofix
AI 9 months ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
|
|
||
| // 未关闭括号 | ||
| { | ||
| wrong: /\((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*$/, |
Check failure
Code scanning / CodeQL
Inefficient regular expression High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 months ago
To fix the issue, we need to rewrite the regular expression to eliminate the ambiguity that causes exponential backtracking. Specifically, we can replace the ambiguous [^)(]+ with a more precise sub-expression that avoids overlapping matches. Additionally, we can use a more structured approach to match nested parentheses, such as leveraging a library like xregexp for recursive patterns if necessary.
In this case, we will rewrite the regex to use a non-ambiguous pattern for matching nested parentheses. The updated regex will ensure linear time complexity while preserving the original functionality.
| @@ -189,3 +189,3 @@ | ||
| { | ||
| wrong: /\((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*$/, | ||
| wrong: /\((?:[^)(]*\((?:[^)(]*\([^)(]*\))*[^)(]*\))*[^)(]*$/, | ||
| correct: (match: string) => `${match})`, |
|
|
||
| // 未关闭括号 | ||
| { | ||
| wrong: /\((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*$/, |
Check failure
Code scanning / CodeQL
Inefficient regular expression High
Copilot Autofix
AI 9 months ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.