fix(pdf): sanitise Content-Disposition filename, fix triagedByName test fixture

This commit is contained in:
2026-07-28 17:11:16 +08:00
parent 28929f40e2
commit 740c6da3ba
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -146,7 +146,8 @@ export async function GET(
closedAt: incident.closedAt instanceof Date ? incident.closedAt.toISOString() : (incident.closedAt as string | null),
})
const filename = `incident-report-${incident.referenceNo ?? id}.pdf`
const safeRef = (incident.referenceNo ?? id).replace(/[^A-Za-z0-9\-_.]/g, '_')
const filename = `incident-report-${safeRef}.pdf`
return new NextResponse(Buffer.from(pdfBytes), {
status: 200,
+1 -1
View File
@@ -42,7 +42,7 @@ const MOCK_INCIDENT = {
isDangerousOccurrence: false,
isOccupationalDisease: false,
lostDays: null,
triagedBy: 'Supervisor',
triagedByName: 'Supervisor',
triagedAt: new Date('2026-07-01T10:00:00Z'),
triageNotes: 'Reviewed',
closedAt: new Date('2026-07-20T15:00:00Z'),