Escape backslashes in path string to discovered vite config#13814
Escape backslashes in path string to discovered vite config#13814danegsta merged 1 commit intodotnet:mainfrom
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13814Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13814" |
There was a problem hiding this comment.
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
| var aspireConfig = AspireViteConfig | ||
| .Replace(AspireViteRelativeConfigToken, relativeConfigPath.Replace("\\", "/"), StringComparison.Ordinal) | ||
| .Replace(AspireViteAbsoluteConfigToken, absoluteConfigPath, StringComparison.Ordinal); | ||
| .Replace(AspireViteAbsoluteConfigToken, absoluteConfigPath.Replace("\\", "\\\\"), StringComparison.Ordinal); |
There was a problem hiding this comment.
Is there anyway to test this? Do we have tests for it?
There was a problem hiding this comment.
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).
|
/backport to release/13.1 |
|
Started backporting to release/13.1: https://github.com/dotnet/aspire/actions/runs/20857958095 |
Description
Wasn't properly escaping backslashes when logging the path to the discovered vite config.