fix(daemon): preserve backslashes in parseCommandLine on Windows (#15642)

* fix(daemon): preserve backslashes in parseCommandLine on Windows

Only treat backslash as escape when followed by a quote or another
backslash. Bare backslashes are kept as-is so Windows paths survive.

Fixes #15587

* fix(daemon): preserve UNC backslashes in schtasks parsing (#15642) (thanks @arosstale)

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
This commit is contained in:
Artale
2026-02-13 19:27:06 +01:00
committed by GitHub
parent 39e6e4cd2c
commit ab0d8ef8c1
3 changed files with 67 additions and 9 deletions

View File

@@ -59,16 +59,14 @@ function parseCommandLine(value: string): string[] {
const args: string[] = [];
let current = "";
let inQuotes = false;
let escapeNext = false;
for (const char of value) {
if (escapeNext) {
current += char;
escapeNext = false;
continue;
}
if (char === "\\") {
escapeNext = true;
for (let i = 0; i < value.length; i++) {
const char = value[i];
// `buildTaskScript` only escapes quotes (`\"`).
// Keep all other backslashes literal so drive and UNC paths are preserved.
if (char === "\\" && i + 1 < value.length && value[i + 1] === '"') {
current += value[i + 1];
i++;
continue;
}
if (char === '"') {