diff --git a/apps/dokploy/__test__/wss/readValidDirectory.test.ts b/apps/dokploy/__test__/wss/readValidDirectory.test.ts index 29d3152eb0..1394f0c2f5 100644 --- a/apps/dokploy/__test__/wss/readValidDirectory.test.ts +++ b/apps/dokploy/__test__/wss/readValidDirectory.test.ts @@ -94,4 +94,27 @@ describe("readValidDirectory (path traversal)", () => { ), ).toBe(true); }); + + it("returns true for Next.js static export chunk paths", () => { + expect( + readValidDirectory( + `${BASE}/applications/myapp/code/out/_next/static/chunks/0.qc0y~mo5hro.js`, + ), + ).toBe(true); + expect( + readValidDirectory( + `${BASE}/applications/myapp/code/out/_next/static/chunks/__next.!KGFwcCk.txt`, + ), + ).toBe(true); + expect( + readValidDirectory( + `${BASE}/applications/myapp/code/out/(app)/$id.js`, + ), + ).toBe(true); + expect( + readValidDirectory( + `${BASE}/applications/myapp/code/out/components=page,chunk+1.js`, + ), + ).toBe(true); + }); }); diff --git a/packages/server/src/wss/utils.ts b/packages/server/src/wss/utils.ts index ec590399d3..f6817da68a 100644 --- a/packages/server/src/wss/utils.ts +++ b/packages/server/src/wss/utils.ts @@ -40,7 +40,7 @@ export const readValidDirectory = ( directory: string, serverId?: string | null, ) => { - if (!/^[\w/. :[\]-]{1,500}$/.test(directory)) { + if (!/^[\w/. :()[\]~@!$=%+,.-]{1,500}$/.test(directory)) { return false; }