Skip to content

Conversation

@Git-Hub-Chris
Copy link
Owner

Potential fix for https://github.com/Git-Hub-Chris/MicrosoftVsCode/security/code-scanning/41

The problem is that in the argument to RegExp, the string \.${replaceeScope} only escapes the dot if written as '\\.' + replaceeScope or `\\.${replaceeScope}`, because in a JavaScript string, \. is just ., and in a regex pattern, . is a wildcard, not a literal dot. So to produce a regex that matches a literal dot, we need a double backslash in the JavaScript string, so that the regex engine sees a single backslash and interprets \. as a literal dot.

To fix this, change line 12 to:

const regex = new RegExp(`\\.${replaceeScope}`, 'g');

This ensures the resulting regex is matching a literal dot followed by the same replacement scope (like .json), rather than any character plus the replacement scope.

No other parts of the code need to be changed.


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

…ion character escape

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Christopher Birnie-Browne <153604499+Git-Hub-Chris@users.noreply.github.com>
@Git-Hub-Chris Git-Hub-Chris marked this pull request as ready for review September 21, 2025 03:49
@Git-Hub-Chris Git-Hub-Chris merged commit c8bb311 into Main Sep 21, 2025
11 checks passed
@Git-Hub-Chris Git-Hub-Chris deleted the alert-autofix-41 branch September 21, 2025 03:49
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