mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 03:51:25 +00:00
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:
@@ -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 === '"') {
|
||||
|
||||
Reference in New Issue
Block a user