Skip to content

Potential fix for code scanning alert no. 4: Inefficient regular expression#39

Merged
jmaxdev merged 3 commits intomainfrom
alert-autofix-4
Apr 19, 2026
Merged

Potential fix for code scanning alert no. 4: Inefficient regular expression#39
jmaxdev merged 3 commits intomainfrom
alert-autofix-4

Conversation

@jmaxdev
Copy link
Copy Markdown
Collaborator

@jmaxdev jmaxdev commented Apr 19, 2026

Potential fix for https://github.com/TrixtyAI/ide/security/code-scanning/4

The best fix is to make the repeated inner alternatives mutually exclusive, so the engine has far fewer backtracking choices while matching bold markdown content.

In apps/desktop/src/addons/builtin.language.markdown/index.ts, update the strong-emphasis **...** regex on line 85:

  • Current: \*\*([^\\*]|@escapes|\*(?!\*))+\*\*
  • Replace with: \*\*(?:@escapes|[^\\*]|\*(?!\*))+\*\*

Why this works:

  • Putting @escapes first and making the group non-capturing reduces ambiguity when a backslash introduces an escape sequence.
  • Keeping the same three logical cases preserves functionality: escaped markdown chars, normal non-\/* chars, and single * not followed by *.
  • Non-capturing (?:...) avoids unnecessary capture bookkeeping.

No imports, new methods, or dependencies are needed.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Comment thread apps/desktop/src/addons/builtin.language.markdown/index.ts Fixed
jmaxdev and others added 2 commits April 19, 2026 02:38
…ession

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…expression'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@jmaxdev jmaxdev marked this pull request as ready for review April 19, 2026 05:38
@jmaxdev jmaxdev merged commit 0e5bfcb into main Apr 19, 2026
8 checks passed
@jmaxdev jmaxdev deleted the alert-autofix-4 branch April 19, 2026 06:41
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.

2 participants