@devries-cameron20 / t3code-1 / commits / 3e99019af8
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Serve attachments using URL-encoded relative paths

- Read attachment route paths without URI decoding before normalization - Align test fixture paths with encoded thread/message/file names

Julius Marminge committed Feb 27, 2026 at 21:07 UTC 3e99019af85e67cdbc5be0ef95b71662ebe683e7
2 files changed +4 -11
apps/server/src/wsServer.test.ts
+3 -3
@@ -492,9 +492,9 @@ describe("WebSocket Server", () => {
492 const attachmentPath = path.join(
493 stateDir,
494 "attachments",
495 - "thread folder",
496 - "message folder",
497 - "file name.png",
495 + "thread%20folder",
496 + "message%20folder",
497 + "file%20name.png",
498 );
499 fs.mkdirSync(path.dirname(attachmentPath), { recursive: true });
500 fs.writeFileSync(attachmentPath, Buffer.from("hello-encoded-attachment"));
apps/server/src/wsServer.ts
+1 -8
@@ -251,14 +251,7 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return<
251
252 if (url.pathname.startsWith(ATTACHMENTS_ROUTE_PREFIX)) {
253 const attachmentsRoot = path.resolve(path.join(serverConfig.stateDir, "attachments"));
254 - const encodedRelativePath = url.pathname.slice(ATTACHMENTS_ROUTE_PREFIX.length);
255 - let rawRelativePath: string;
256 - try {
257 - rawRelativePath = decodeURIComponent(encodedRelativePath);
258 - } catch {
259 - respond(400, { "Content-Type": "text/plain" }, "Invalid attachment path");
260 - return;
261 - }
254 + const rawRelativePath = url.pathname.slice(ATTACHMENTS_ROUTE_PREFIX.length);
255 const normalizedRelativePath = path.normalize(rawRelativePath).replace(/^[/\\]+/, "");
256
257 if (