Skip to content

Escape special regex characters in additionalCompilerNames#768

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-makefile-compiler-names
Draft

Escape special regex characters in additionalCompilerNames#768
Copilot wants to merge 3 commits intomainfrom
copilot/fix-makefile-compiler-names

Conversation

Copy link
Contributor

Copilot AI commented Jan 29, 2026

User-provided compiler names in makefile.additionalCompilerNames containing regex metacharacters (e.g., nios2-elf-g++) cause "Invalid regular expression: Nothing to repeat" exceptions during configure. Built-in compilers like g++ are pre-escaped in source, but user additions were not.

Changes

  • src/util.ts: Add escapeStringForRegex() to escape regex metacharacters (. * + ? ^ $ { } ( ) | [ ] \)
  • src/parser.ts: Escape additionalCompilerNames entries before regex construction
  • src/test/fakeSuite/extension.test.ts: Add test suite for regex escaping

Example

Before (throws):

// User sets additionalCompilerNames: ["nios2-elf-g++"]
versionedToolNames.push(`${prefixRegex}${compiler}${suffixRegex}`);
// Results in: ...nios2-elf-g++... → regex fails on unescaped ++

After:

const escapedCompiler = util.escapeStringForRegex(compiler);
versionedToolNames.push(`${prefixRegex}${escapedCompiler}${suffixRegex}`);
// Results in: ...nios2-elf-g\+\+... → valid regex

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 0psvsblobprodwus2145.vsblob.vsassets.io
    • Triggering command: /usr/local/bin/node /usr/local/bin/node /usr/local/bin/yarn install (dns block)
  • 8wdvsblobprodwus2137.vsblob.vsassets.io
    • Triggering command: /usr/local/bin/node /usr/local/bin/node /usr/local/bin/yarn install (dns block)
  • b15vsblobprodwus2164.vsblob.vsassets.io
    • Triggering command: /usr/local/bin/node node /usr/local/bin/npm install (dns block)
  • b53vsblobprodwus2154.vsblob.vsassets.io
    • Triggering command: /usr/local/bin/node /usr/local/bin/node /usr/local/bin/yarn install (dns block)
  • isovsblobprodwus211.vsblob.vsassets.io
    • Triggering command: /usr/local/bin/node /usr/local/bin/node /usr/local/bin/yarn install (dns block)
  • lusvsblobprodwus2166.vsblob.vsassets.io
    • Triggering command: /usr/local/bin/node node /usr/local/bin/npm install (dns block)
  • pkwvsblobprodwus2126.vsblob.vsassets.io
    • Triggering command: /usr/local/bin/node node /usr/local/bin/npm install (dns block)
  • v41vsblobprodwus2175.vsblob.vsassets.io
    • Triggering command: /usr/local/bin/node /usr/local/bin/node /usr/local/bin/yarn install (dns block)
  • vd2vsblobprodwus2150.vsblob.vsassets.io
    • Triggering command: /usr/local/bin/node /usr/local/bin/node /usr/local/bin/yarn install (dns block)
  • vjmvsblobprodwus2182.vsblob.vsassets.io
    • Triggering command: /usr/local/bin/node node /usr/local/bin/npm install (dns block)
  • vm9vsblobprodwus2190.vsblob.vsassets.io
    • Triggering command: /usr/local/bin/node node /usr/local/bin/npm install (dns block)
  • wlnvsblobprodwus2188.vsblob.vsassets.io
    • Triggering command: /usr/local/bin/node /usr/local/bin/node /usr/local/bin/yarn install (dns block)
  • y1rvsblobprodwus2136.vsblob.vsassets.io
    • Triggering command: /usr/local/bin/node /usr/local/bin/node /usr/local/bin/yarn install (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Avoid exception by improving makefile.additionalCompilerNames handling to automatically escape characters like +</issue_title>
<issue_description>Hi,

I'm trying to setup makefile tools to be able to cross compile for Nios II within vscode and have run into the same issue when attempting to run Makefile: Configure, Makefile: Clean Configure. On attempting to Debug or Run I see: Cannot run because there is no launch configuration set and the list of launch targets is empty. Double check the makefile configuration and the build target. (The build target is set to all and the build is successful) I have defined a launch target in a launch.json file but there doesn't seem to be a way of selecting this or associating it with my Makefile project.

When I attempt to run Makefile: Configure I see the following output:

The project needs a configure to populate the launch targets correctly.
Saving opened files before build.
Generating configuration cache with command: 'make all --dry-run --keep-going --print-directory'
Writing the dry-run output: /home/user/.config/Code/User/workspaceStorage/6f0a7708412f42e0089d7c9c03759fd3/ms-vscode.makefile-tools/dryrun.log
Generating dry-run elapsed time: 0.175
Preprocessing: "/home/user/.config/Code/User/workspaceStorage/6f0a7708412f42e0089d7c9c03759fd3/ms-vscode.makefile-tools/dryrun.log"
Preprocess elapsed time: 0
Parsing for IntelliSense.
Updating the CppTools IntelliSense Configuration Provider.
Parsing dry-run output for CppTools Custom Configuration Provider.
Exception thrown during the configure process: Invalid regular expression: /^[\s"](.?)((([a-zA-Z0-9-.]*-)*ccache(-[a-zA-Z0-9-.]))|(([a-zA-Z0-9-.]*-)*clang++(-[a-zA-Z0-9-.]))|(([a-zA-Z0-9-.]*-)*clang-cl(-[a-zA-Z0-9-.]))|(([a-zA-Z0-9-.]*-)*clang-cpp(-[a-zA-Z0-9-.]))|(([a-zA-Z0-9-.]*-)*clang(-[a-zA-Z0-9-.]))|(([a-zA-Z0-9-.]*-)*gcc(-[a-zA-Z0-9-.]))|(([a-zA-Z0-9-.]*-)*gpp(-[a-zA-Z0-9-.]))|(([a-zA-Z0-9-.]*-)*cpp(-[a-zA-Z0-9-.]))|(([a-zA-Z0-9-.]*-)*icc(-[a-zA-Z0-9-.]))|(([a-zA-Z0-9-.]*-)*cc(-[a-zA-Z0-9-.]))|(([a-zA-Z0-9-.]*-)*icl(-[a-zA-Z0-9-.]))|(([a-zA-Z0-9-.]*-)*cl(-[a-zA-Z0-9-.]))|(([a-zA-Z0-9-.]*-)*g++(-[a-zA-Z0-9-.]))|(([a-zA-Z0-9-.]*-)*c++(-[a-zA-Z0-9-.]))|(([a-zA-Z0-9-.]*-)*nios2-elf-gcc(-[a-zA-Z0-9-.]))|(([a-zA-Z0-9-.]*-)*nios2-elf-ar(-[a-zA-Z0-9-.]))|(([a-zA-Z0-9-.]*-)*nios2-elf-g++(-[a-zA-Z0-9-.]))|(([a-zA-Z0-9-.]*-)*nios2-elf-nm(-[a-zA-Z0-9-.])))(\s|"\s)(.*)$/gm: Nothing to repeat</issue_description>

<agent_instructions>Please add tests if possible.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@gcampbell-msft Could you help us by providing some more information:
  1. A repro project so that we can better investigate.
  2. Which version of the extension this started in? Does it reproduce in older versions?
  3. If it only reproduces in the most recent official release version, it'd be great if you could install the pre-release and deduce which pre-release version this starts reproducing in.

Thanks! @Yingzi1234 FYI.</comment_new>
<comment_new>@gcampbell-msft
@Amy-Li03 @gpaterson @TurnOffNOD I have found the issue. Thanks for the repro steps and the direction regarding the makefile.additionalCompilerNames. The issue is that the "+" character messes up the regex, and it needs to be escaped.

This is likely something that we should improve in our handling of makefile.additionalCompilerNames, but the quickest thing you can do is add \\ before the + characters in order to escape them</comment_new>
<comment_new>@gcampbell-msft
Please let us know if that works around your issue and if so, we'll close the issue 👍</comment_new>
<comment_new>@gcampbell-msft
@TurnOffNOD To confirm, are you saying both work?

Technically speaking, having one backslash would be more correct because it's explicitly saying to escape the + character, but both should work and I think our code technically prepares for \ as well</comment_new>
<comment_new>@gcampbell-msft
@TurnOffNOD Thanks for the testing!

I'll slightly update this issue since there is a workaround to be an enhancement request to better handle the makefile.additionalCompilerNames field to handle the escaping without the user having to specify it. </comment_new>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 29, 2026 19:43
…ling

Co-authored-by: snehara99 <113148726+snehara99@users.noreply.github.com>
Co-authored-by: snehara99 <113148726+snehara99@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix exception by improving makefile.additionalCompilerNames handling Escape special regex characters in additionalCompilerNames Jan 29, 2026
Copilot AI requested a review from snehara99 January 29, 2026 19:48
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.

Avoid exception by improving makefile.additionalCompilerNames handling to automatically escape characters like +

2 participants