diff --git a/src/app/api/workspaces/[id]/calendar.ics/route.ts b/src/app/api/workspaces/[id]/calendar.ics/route.ts index 1c88336..0502941 100644 --- a/src/app/api/workspaces/[id]/calendar.ics/route.ts +++ b/src/app/api/workspaces/[id]/calendar.ics/route.ts @@ -56,11 +56,17 @@ export async function GET( membership.workspace.name ) + // Sanitize filename for HTTP headers (remove non-ASCII characters) + const safeFilename = membership.workspace.name + .replace(/[^\x00-\x7F]/g, '') // Remove non-ASCII + .replace(/[<>:"/\\|?*]/g, '-') // Replace invalid filename chars + .trim() || 'appointments' + return new NextResponse(icalContent, { status: 200, headers: { 'Content-Type': 'text/calendar; charset=utf-8', - 'Content-Disposition': `attachment; filename="${membership.workspace.name}-appointments.ics"`, + 'Content-Disposition': `attachment; filename="${safeFilename}-appointments.ics"`, 'Cache-Control': 'no-cache, no-store, must-revalidate', }, })