Skip to content

Potential fix for code scanning alert no. 7: Inefficient regular expression#42

Merged
jmaxdev merged 2 commits intomainfrom
alert-autofix-7
Apr 19, 2026
Merged

Potential fix for code scanning alert no. 7: Inefficient regular expression#42
jmaxdev merged 2 commits intomainfrom
alert-autofix-7

Conversation

@jmaxdev
Copy link
Copy Markdown
Collaborator

@jmaxdev jmaxdev commented Apr 19, 2026

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

To fix this safely, make the repeated content inside link text unambiguous and avoid the nested/expanded alternation that can trigger heavy backtracking.

Best fix here: replace line 92’s ((?:[^\]\\]|@escapes)*) with an equivalent-but-safer form that consumes either:

  • runs of non-special chars, or
  • a single escaped char pair (\\.).

In this file, update only the regex on line 92 in tokenizer.linecontent:

  • from: [/(!?\[)((?:[^\]\\]|@escapes)*)(\]\([^\)]+\))/, ...]
  • to: [/(!?\[)((?:[^\\\]]+|\\.)*)(\]\([^)]+\))/, ...]

This preserves functionality (link text with escapes) while reducing backtracking risk.

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

Comment thread apps/desktop/src/addons/builtin.language.markdown/index.ts Fixed
@jmaxdev jmaxdev marked this pull request as ready for review April 19, 2026 06:02
jmaxdev and others added 2 commits April 19, 2026 03:43
…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 merged commit 4a28383 into main Apr 19, 2026
7 checks passed
@jmaxdev jmaxdev deleted the alert-autofix-7 branch April 19, 2026 06:44
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