Update filesystem/pathexists endpoint to use existing isSameOrSubPath func

This commit is contained in:
advplyr
2026-04-18 16:24:48 -05:00
parent b27f21fd95
commit 24cab79c66

View File

@@ -117,7 +117,7 @@ class FileSystemController {
filepath = fileUtils.filePathToPOSIX(filepath)
// Ensure filepath is inside library folder (prevents directory traversal)
if (!filepath.startsWith(libraryFolder.path)) {
if (!fileUtils.isSameOrSubPath(libraryFolder.path, filepath)) {
Logger.error(`[FileSystemController] Filepath is not inside library folder: ${filepath}`)
return res.sendStatus(400)
}