Skip to content

Commit bd8ba12

Browse files
committed
fix(server): allow plus, at, and valid path characters in readValidDirectory
1 parent 72a554d commit bd8ba12

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

‎apps/dokploy/__test__/wss/readValidDirectory.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,32 @@ describe("readValidDirectory (path traversal)", () => {
9494
),
9595
).toBe(true);
9696
});
97+
98+
it("returns true for SvelteKit routes with + prefix and @ symbols", () => {
99+
expect(
100+
readValidDirectory(
101+
`${BASE}/applications/myapp/code/src/routes/+page.svelte`,
102+
),
103+
).toBe(true);
104+
expect(
105+
readValidDirectory(
106+
`${BASE}/applications/myapp/code/src/routes/+layout.svelte`,
107+
),
108+
).toBe(true);
109+
expect(
110+
readValidDirectory(
111+
`${BASE}/applications/myapp/code/src/routes/+server.ts`,
112+
),
113+
).toBe(true);
114+
expect(
115+
readValidDirectory(
116+
`${BASE}/applications/myapp/code/src/routes/+error.svelte`,
117+
),
118+
).toBe(true);
119+
expect(
120+
readValidDirectory(
121+
`${BASE}/applications/myapp/code/node_modules/@types/node/index.d.ts`,
122+
),
123+
).toBe(true);
124+
});
97125
});

‎packages/server/src/wss/utils.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const readValidDirectory = (
4040
directory: string,
4141
serverId?: string | null,
4242
) => {
43-
if (!/^[\w/. :[\]-]{1,500}$/.test(directory)) {
43+
if (!/^[\w/. :[\]+@~(),=%-]{1,500}$/.test(directory)) {
4444
return false;
4545
}
4646

0 commit comments

Comments
 (0)