diff --git a/apps/server/src/wsServer.test.ts b/apps/server/src/wsServer.test.ts index c56ed157a06a5f1e706f13b184d45dfb7189d380..72847866726f041337cb2e099a561f55161cba72 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.ts index 3e48ecc544c16b6f782638503c32989bdb526891..d382ab9d3e90bacc5c561f0d90f0c78164797802 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 (