Fix: Undo Path Validation for coming back on a classic one

This commit is contained in:
MasterAcnolo
2026-02-18 14:43:40 +01:00
parent 32c9a66a35
commit 74fcdbb738
4 changed files with 32 additions and 47 deletions

View File

@@ -12,35 +12,10 @@ function isValidUrl(url) {
}
function isSafePath(folder) {
if (!folder || typeof folder !== "string") return false;
try {
// Normalize path and resolve symlinks
const resolved = path.resolve(folder).toLowerCase().replace(/\//g, "\\");
// Block Windows system directories (on any drive)
const unsafePaths = [
"\\windows\\",
"\\system32\\",
"\\program files\\",
"\\program files (x86)\\",
"\\programdata\\",
"\\$recycle.bin\\",
"\\system volume information\\"
];
// Check if path contains any unsafe directory
if (unsafePaths.some(unsafe => resolved.includes(unsafe))) {
return false;
}
// Allow all drives (C:, D:, E:, etc.) but block system folders
return true;
} catch (err) {
// In case of path resolution error
return false;
}
if (!folder || folder.length < 3) return false;
const unsafe = ["System32", "\\Windows"];
const resolved = path.resolve(folder);
return !unsafe.some(u => resolved.includes(u));
}
module.exports = { isValidUrl, isSafePath };