Skip to content

Commit 63ccad6

Browse files
fix: handle invalid static path encoding (#36)
Co-authored-by: RissRIce <rissrice2105-agent@users.noreply.github.com>
1 parent 3ceddaa commit 63ccad6

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

apps/commandboard-web/server.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,18 @@ createServer((request, response) => {
3535
return;
3636
}
3737

38-
const file = resolveStaticPath(url.pathname);
38+
let file;
39+
try {
40+
file = resolveStaticPath(url.pathname);
41+
} catch (error) {
42+
if (error instanceof URIError) {
43+
response.writeHead(400, { "content-type": "text/plain; charset=utf-8" });
44+
response.end("Invalid path encoding");
45+
return;
46+
}
47+
throw error;
48+
}
49+
3950
if (!file) {
4051
response.writeHead(403);
4152
response.end("Forbidden");

0 commit comments

Comments
 (0)