Skip to content

Escape backslashes in path string to discovered vite config#13814

Merged
danegsta merged 1 commit intodotnet:mainfrom
danegsta:danegsta/vitePath
Jan 9, 2026
Merged

Escape backslashes in path string to discovered vite config#13814
danegsta merged 1 commit intodotnet:mainfrom
danegsta:danegsta/vitePath

Conversation

@danegsta
Copy link
Member

@danegsta danegsta commented Jan 9, 2026

Description

Wasn't properly escaping backslashes when logging the path to the discovered vite config.

Copilot AI review requested due to automatic review settings January 9, 2026 02:08
@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13814

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13814"

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where backslashes in Windows file paths were not properly escaped when embedding the absolute path to the discovered Vite config into a JavaScript string template. Without proper escaping, the generated JavaScript would contain invalid escape sequences on Windows systems, potentially causing syntax errors or incorrect path display.

Key Change:

  • Added .Replace("\\", "\\\\") to escape backslashes in the absolute config path before inserting it into the JavaScript template string

@danegsta danegsta enabled auto-merge (squash) January 9, 2026 15:33
@danegsta danegsta added the area-integrations Issues pertaining to Aspire Integrations packages label Jan 9, 2026
var aspireConfig = AspireViteConfig
.Replace(AspireViteRelativeConfigToken, relativeConfigPath.Replace("\\", "/"), StringComparison.Ordinal)
.Replace(AspireViteAbsoluteConfigToken, absoluteConfigPath, StringComparison.Ordinal);
.Replace(AspireViteAbsoluteConfigToken, absoluteConfigPath.Replace("\\", "\\\\"), StringComparison.Ordinal);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anyway to test this? Do we have tests for it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only way would be to explicitly create the project in a folder that starts with characters that lead to an invalid sequence when combined with a backslash. There are end-to-end tests that run various scenarios, I’ll check to see if they cover Vite with HTTPS (its opt-in currently so they may not).

@danegsta danegsta merged commit eeadad9 into dotnet:main Jan 9, 2026
567 of 572 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 13.2 milestone Jan 9, 2026
@danegsta
Copy link
Member Author

danegsta commented Jan 9, 2026

/backport to release/13.1

@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

Started backporting to release/13.1: https://github.com/dotnet/aspire/actions/runs/20857958095

@github-actions github-actions bot locked and limited conversation to collaborators Feb 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-integrations Issues pertaining to Aspire Integrations packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants