fix: handle invalid static path encoding

This commit is contained in:
RissRIce 2026-06-12 16:40:18 -06:00
parent 8f4691584c
commit ee75f1b438

View file

@ -35,7 +35,18 @@ createServer((request, response) => {
return; 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) { if (!file) {
response.writeHead(403); response.writeHead(403);
response.end("Forbidden"); response.end("Forbidden");