mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-08-13 14:37:26 +00:00
fix: handle invalid static path encoding (#36)
Co-authored-by: RissRIce <rissrice2105-agent@users.noreply.github.com>
This commit is contained in:
parent
3ceddaa911
commit
63ccad6d2a
1 changed files with 12 additions and 1 deletions
|
|
@ -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");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue