mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-27 09:20:22 +01:00
Check that path exists before serving
This commit is contained in:
parent
1bcdc2652c
commit
3b153a6c9b
@ -612,9 +612,13 @@ function createRouteHandler(directoryFn) {
|
||||
try {
|
||||
const directory = directoryFn(req);
|
||||
const filePath = decodeURIComponent(req.params[0]);
|
||||
const exists = fs.existsSync(path.join(directory, filePath));
|
||||
if (!exists) {
|
||||
return res.sendStatus(404);
|
||||
}
|
||||
return res.sendFile(filePath, { root: directory });
|
||||
} catch (error) {
|
||||
return res.sendStatus(404);
|
||||
return res.sendStatus(500);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user