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:
@ -27,4 +27,9 @@ export default defineConfigWithVueTs(
|
|||||||
files: ['src/**/__tests__/*'],
|
files: ['src/**/__tests__/*'],
|
||||||
},
|
},
|
||||||
skipFormatting,
|
skipFormatting,
|
||||||
|
{
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/no-explicit-any': 'off',
|
||||||
|
},
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@ -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 if (queryResult.length > 1) res.status(500).json({ message: 'Multiple scans found with the same ID' });
|
||||||
else {
|
else {
|
||||||
const scan = queryResult[0];
|
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');
|
res.download(filePath, scan.name + '.pdf');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user