Skip to content

Conversation

Copy link

Copilot AI commented Dec 9, 2025

File paths with parentheses and other shell special characters were not escaped when passed to the CLI script, causing command execution failures on macOS and other platforms.

Changes

  • CodacyCli.preparePathForExec(): Wraps paths in double quotes and escapes $, `, \, " to handle all shell metacharacters safely
  • WinWSLCodacyCli: Removed duplicate space escaping logic; delegates to parent class after WSL path conversion. Normalized drive letters to lowercase
  • MacCodacyCli.install(): Removed redundant double quotes since preparePathForExec() now returns quoted paths
  • Tests: Added comprehensive test suite covering parentheses, spaces, quotes, brackets, wildcards, and other special characters

Example

Before:

protected preparePathForExec(path: string): string {
  return path  // file(test).ts → shell interprets () as subshell
}

After:

protected preparePathForExec(path: string): string {
  const escaped = path.replace(/([\\$"`])/g, '\\$1')
  return `"${escaped}"`  // file(test).ts → "file(test).ts"
}

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:

  • artifacts.codacy.com
    • Triggering command: /usr/bin/curl curl REDACTED -o ./api-v3/api-swagger.yaml --create-dirs (dns block)

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

Original prompt

We have this BUG created in Jira:

[CLI] Vscode plugin is not escaping parenthesis on filepaths

The Vscode plugin is not escaping parenthesis on filepaths, which makes the calls to the cli.sh script break. This was reported on MacOS, but could be happening in other OSs as well.

If possible, first create a unit test to check if the plugin is able to escape all possible characters on filepaths and then change the code accordingly so they are all properly escaped as expected, so a fix is created for all of them and not just for the parenthesis.


Fix the bug and create a pull request with the proposed solution.


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

Copilot AI self-assigned this Dec 9, 2025
@codacy-production
Copy link

Codacy's Analysis Summary

0 new issue (≤ 1 medium issue)
0 new security issue (≤ 0 issue)

Review Pull Request in Codacy →

AI Reviewer available: add the codacy-review label to get contextual insights without leaving GitHub.

@codacy-production
Copy link

codacy-production bot commented Dec 9, 2025

Codacy's Analysis Summary

0 new issue (≤ 1 medium issue)
0 new security issue (≤ 0 issue)
33 complexity
0 duplications

Review Pull Request in Codacy →

AI Reviewer available: add the codacy-review label to get contextual insights without leaving GitHub.

@codacy-production
Copy link

codacy-production bot commented Dec 9, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.08% 33.33%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (de0b061) 5422 1356 25.01%
Head commit (f133c31) 5428 (+6) 1362 (+6) 25.09% (+0.08%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#172) 15 5 33.33%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Copilot AI changed the title [WIP] Fix escaping of characters in filepaths for Vscode plugin Fix shell special character escaping in CLI file paths Dec 9, 2025
Copilot AI requested a review from alerizzo December 9, 2025 12:41
@alerizzo alerizzo changed the title Fix shell special character escaping in CLI file paths [fix] Fix shell special character escaping in CLI file paths CF-2117 Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants