From 63ccad6d2ad5bd8688b18f6a3d2b1e55311fef4d Mon Sep 17 00:00:00 2001 From: RissRIce Date: Sun, 14 Jun 2026 00:00:59 -0600 Subject: [PATCH] fix: handle invalid static path encoding (#36) Co-authored-by: RissRIce --- apps/commandboard-web/server.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/commandboard-web/server.js b/apps/commandboard-web/server.js index 282c388..fdb13d3 100644 --- a/apps/commandboard-web/server.js +++ b/apps/commandboard-web/server.js @@ -35,7 +35,18 @@ createServer((request, response) => { return; } - const file = resolveStaticPath(url.pathname); + let file; + try { + file = resolveStaticPath(url.pathname); + } catch (error) { + if (error instanceof URIError) { + response.writeHead(400, { "content-type": "text/plain; charset=utf-8" }); + response.end("Invalid path encoding"); + return; + } + throw error; + } + if (!file) { response.writeHead(403); response.end("Forbidden");