fix: handle invalid static path encoding (#36)

Co-authored-by: RissRIce <rissrice2105-agent@users.noreply.github.com>
This commit is contained in:
RissRIce 2026-06-14 00:00:59 -06:00 committed by GitHub
parent 3ceddaa911
commit 63ccad6d2a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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");