Fix: Centralize default download path and enhance path validation logic

This commit is contained in:
MasterAcnolo
2026-02-17 23:29:31 +01:00
parent 45e0840fea
commit 32c9a66a35
6 changed files with 94 additions and 40 deletions

View File

@@ -16,11 +16,14 @@ async function downloadController(req, res) {
};
if (!options.url || !isValidUrl(options.url)) return res.status(400).send("❌ Invalid URL !");
if (options.outputFolder && !isSafePath(options.outputFolder)) return res.status(400).send("❌ Save Path Not Allowed.");
if (options.outputFolder && !isSafePath(options.outputFolder)) {
logger.warn(`Unsafe download path rejected: ${options.outputFolder}`);
return res.status(400).send("❌ Save Path Not Allowed.");
}
// Get output folder when the download is finished,
const filePath = await fetchDownload(options, listeners, speedListeners);
notifyDownloadFinished(filePath);
// Get output folder when the download is finished
const outputFolder = await fetchDownload(options, listeners, speedListeners);
notifyDownloadFinished(outputFolder);
res.send("✅ Download Done !");
} catch (err) {