@geml/logseq-sync 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/watcher/bin/logseq-sync.mjs +20 -5
package/package.json
CHANGED
|
@@ -135,7 +135,9 @@ for (let i = 0; i < args.length; i++) {
|
|
|
135
135
|
} else if (arg === "--api-server-token") {
|
|
136
136
|
needValue(i, "--api-server-token");
|
|
137
137
|
flags.apiServerToken = args[++i];
|
|
138
|
-
} else if (arg.startsWith("
|
|
138
|
+
} else if (arg.startsWith("-")) {
|
|
139
|
+
// One dash included: "-graph demo" once sailed through as a graph literally
|
|
140
|
+
// named "-graph" and a vault named "demo" — a typo must stop, not sync.
|
|
139
141
|
console.error(`Error: Unknown flag "${arg}". Run \`logseq-sync --help\` for usage.`);
|
|
140
142
|
process.exit(2);
|
|
141
143
|
} else if (subcommand === null && positional.length === 0 && (arg === "doctor" || arg === "restore")) {
|
|
@@ -395,7 +397,10 @@ if (subcommand === "doctor") doctor();
|
|
|
395
397
|
graphName = resolveGraphOrExit();
|
|
396
398
|
|
|
397
399
|
// Validate graph name to prevent command/path injection
|
|
398
|
-
|
|
400
|
+
// The first character must not be a dash or a dot: the name travels as argv
|
|
401
|
+
// into the exporting CLI, where a leading dash reads as a flag ("-graph"
|
|
402
|
+
// arrived here as a real user typo for --graph), and "." / ".." read as paths.
|
|
403
|
+
if (!/^[a-zA-Z0-9_][a-zA-Z0-9_.-]*$/.test(graphName)) {
|
|
399
404
|
console.error(`Error: Invalid graph name "${graphName}". Only alphanumeric characters, hyphens, and underscores are allowed.`);
|
|
400
405
|
process.exit(2);
|
|
401
406
|
}
|
|
@@ -476,9 +481,19 @@ function runLogseqCli(...cmdArgs) {
|
|
|
476
481
|
});
|
|
477
482
|
}
|
|
478
483
|
|
|
479
|
-
//
|
|
480
|
-
|
|
481
|
-
|
|
484
|
+
// On Windows the npx fallback is an instruction, not a spawn: Node refuses
|
|
485
|
+
// to run a .cmd without a shell (CVE-2024-27980), and routing a user-typed
|
|
486
|
+
// graph name through cmd.exe to get around that is how injection happens.
|
|
487
|
+
// Every prior attempt died as `spawnSync npx.cmd EINVAL`, once every poll.
|
|
488
|
+
if (process.platform === "win32") {
|
|
489
|
+
throw new Error(
|
|
490
|
+
"@logseq/cli is not installed where I can see it. Install it once\n" +
|
|
491
|
+
" (mkdir logseq-cli && cd logseq-cli && npm init -y && npm i @logseq/cli)\n" +
|
|
492
|
+
"and point LOGSEQ_CLI_DIR at that directory — or pass --app-cli <path>\n" +
|
|
493
|
+
"to the desktop app's CLI."
|
|
494
|
+
);
|
|
495
|
+
}
|
|
496
|
+
return execFileSync("npx", ["-y", "@logseq/cli", ...cmdArgs], {
|
|
482
497
|
cwd: cliCwd,
|
|
483
498
|
encoding: "utf8",
|
|
484
499
|
shell: false,
|