Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
Serve attachments using URL-encoded relative paths
Julius Marminge3e99019af85e
diff --git a/apps/server/src/wsServer.test.ts b/apps/server/src/wsServer.test.tsindex c56ed157a..728478667 100644--- a/apps/server/src/wsServer.test.ts+++ b/apps/server/src/wsServer.test.ts@@ -492,9 +492,9 @@ describe("WebSocket Server", () => {const attachmentPath = path.join(stateDir,"attachments",- "thread folder",- "message folder",- "file name.png",+ "thread%20folder",+ "message%20folder",+ "file%20name.png",);fs.mkdirSync(path.dirname(attachmentPath), { recursive: true });fs.writeFileSync(attachmentPath, Buffer.from("hello-encoded-attachment"));diff --git a/apps/server/src/wsServer.ts b/apps/server/src/wsServer.tsindex 3e48ecc54..d382ab9d3 100644--- a/apps/server/src/wsServer.ts+++ b/apps/server/src/wsServer.ts@@ -251,14 +251,7 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return<if (url.pathname.startsWith(ATTACHMENTS_ROUTE_PREFIX)) {const attachmentsRoot = path.resolve(path.join(serverConfig.stateDir, "attachments"));- const encodedRelativePath = url.pathname.slice(ATTACHMENTS_ROUTE_PREFIX.length);- let rawRelativePath: string;- try {- rawRelativePath = decodeURIComponent(encodedRelativePath);- } catch {- respond(400, { "Content-Type": "text/plain" }, "Invalid attachment path");- return;- }+ const rawRelativePath = url.pathname.slice(ATTACHMENTS_ROUTE_PREFIX.length);const normalizedRelativePath = path.normalize(rawRelativePath).replace(/^[/\\]+/, "");if (