feat: Validate scan link format and update file path handling
All checks were successful
deploy / deploy (push) Successful in 2m30s
All checks were successful
deploy / deploy (push) Successful in 2m30s
This commit is contained in:
@ -116,7 +116,12 @@ app.get('/api/music-scans/download/:id', AuthHandler, async (req, res) => {
|
||||
else if (queryResult.length > 1) res.status(500).json({ message: 'Multiple scans found with the same ID' });
|
||||
else {
|
||||
const scan = queryResult[0];
|
||||
const filePath = path.join(UPLOAD_FOLDER, scan.link);
|
||||
if (!scan.link || !scan.link.endsWith('.pdf')) {
|
||||
res.status(400).json({ message: 'Invalid scan link' });
|
||||
return;
|
||||
}
|
||||
const link = path.join(...(scan.link.split('\\')));
|
||||
const filePath = path.join(UPLOAD_FOLDER, link);
|
||||
res.download(filePath, scan.name + '.pdf');
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user