Skip to content
This repository was archived by the owner on Apr 8, 2026. It is now read-only.

Commit b42b38f

Browse files
committed
fix(download): sanitize filename in Content-Disposition header for game downloads
1 parent 4eeb37e commit b42b38f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/controllers/GameController.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,8 @@ export class Games {
407407
}
408408
const fileRes = await fetch(downloadUrl, { headers });
409409
if (!fileRes.ok) return res.status(502).send({ message: 'Failed to fetch game file' });
410-
res.setHeader('Content-Disposition', `attachment; filename="${game.name}.zip"`);
410+
const sanitizedFileName = encodeURIComponent(game.name.replace(/[^a-zA-Z0-9-_\.]/g, '_'));
411+
res.setHeader('Content-Disposition', `attachment; filename="${sanitizedFileName}.zip"`);
411412
res.setHeader('Content-Type', fileRes.headers.get('content-type') || 'application/octet-stream');
412413
const contentLength = fileRes.headers.get('content-length');
413414
if (contentLength) res.setHeader('Content-Length', contentLength);

0 commit comments

Comments
 (0)