Skip to content

Commit

Permalink
Merge pull request #293 from tosuapp/fix/check-file
Browse files Browse the repository at this point in the history
fix: Prevent sending file if it doesnt exists, or it's not a file
  • Loading branch information
KotRikD authored Feb 3, 2025
2 parents 9e72190 + 4f252cd commit 52f333e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/server/scripts/beatmapFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ export function beatmapFileShortcut(

const filePath = path.join(folder, fileName);
const fileStat = fs.statSync(filePath);
if (!fileStat.isFile() || !fs.existsSync(filePath)) {
res.writeHead(404, {
'Content-Type': getContentType(fileName)
});
return res.end();
}

if (req.headers.range) {
const range = req.headers.range.replace('bytes=', '').split('-');
Expand Down

0 comments on commit 52f333e

Please sign in to comment.