mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-08-14 23:07:29 +00:00
fix: handle invalid static path encoding
This commit is contained in:
parent
8f4691584c
commit
ee75f1b438
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