Handle malformed static paths (#31)

Co-authored-by: Codex Microtask Operator <codex-microtask@example.com>
This commit is contained in:
Autowebassat-blip 2026-06-14 07:59:10 +02:00 committed by GitHub
parent 774d461db6
commit d9cf41e5a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -48,7 +48,12 @@ createServer((request, response) => {
}); });
function resolveStaticPath(pathname) { function resolveStaticPath(pathname) {
const decodedPath = decodeURIComponent(pathname); let decodedPath;
try {
decodedPath = decodeURIComponent(pathname);
} catch {
return null;
}
const normalizedPath = normalize(decodedPath).replace(/^(\.\.[/\\])+/, ""); const normalizedPath = normalize(decodedPath).replace(/^(\.\.[/\\])+/, "");
let candidate = join(distDirectory, normalizedPath); let candidate = join(distDirectory, normalizedPath);