fix(exec): ignore malformed drive-less windows exec paths

This commit is contained in:
SnowSky1
2026-04-01 11:21:47 +08:00
committed by Peter Steinberger
parent a26f4d0f3e
commit e6ce31eb54
4 changed files with 43 additions and 0 deletions

View File

@@ -45,6 +45,10 @@ function parseFirstToken(command: string): string | null {
return match ? match[0] : null;
}
function isDriveLessWindowsRootedPath(value: string): boolean {
return process.platform === "win32" && /^:[\\/]/.test(value);
}
function tryResolveRealpath(filePath: string | undefined): string | undefined {
if (!filePath) {
return undefined;
@@ -176,6 +180,9 @@ function resolveExecutableCandidatePathFromResolution(
return undefined;
}
const expanded = raw.startsWith("~") ? expandHomePrefix(raw) : raw;
if (isDriveLessWindowsRootedPath(expanded)) {
return undefined;
}
if (!expanded.includes("/") && !expanded.includes("\\")) {
return undefined;
}