Skip to content

Commit 0d63d41

Browse files
fix: reject Windows drive-relative paths in normalizeRelativePath
1 parent 31de4a5 commit 0d63d41

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

packages/cli/src/lib/app/preview-build-settings.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,11 @@ export function normalizeRelativePath(value: string): string | undefined {
596596
if (raw.length === 0 || raw.split("/").includes("..")) {
597597
return undefined;
598598
}
599+
// Windows drive-relative paths ("C:dir") escape the base directory but
600+
// are not absolute under either path.win32 or path.posix.
601+
if (/^[A-Za-z]:/.test(raw)) {
602+
return undefined;
603+
}
599604

600605
const normalized = path.posix.normalize(raw);
601606
const segments = normalized.split("/");

packages/cli/tests/compute-config.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ describe("normalizeComputeConfig", () => {
144144
expect(issues.join(" ")).toContain("`apps.web.env.vars.EMPTY` must be a non-empty string.");
145145
});
146146

147+
it("rejects roots that escape the config directory, including Windows drive-relative paths", () => {
148+
for (const root of ["C:apps", "C:/apps", "/apps", "..\\apps"]) {
149+
expect(normalizeIssues({ app: { root } }).join(" ")).toContain(
150+
"`app.root` must be a relative path inside the repository.",
151+
);
152+
}
153+
});
154+
147155
it("normalizes build blocks", () => {
148156
const config = normalizeOrThrow(defineComputeConfig({
149157
apps: {

0 commit comments

Comments
 (0)