Handle malformed static paths

This commit is contained in:
Codex Microtask Operator 2026-06-12 18:35:13 +02:00
parent 8f4691584c
commit b10efcc1bf

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