From e5db48f82b93d7cc29ff6cdd5479ab7bf4a5a6f9 Mon Sep 17 00:00:00 2001 From: Gemini Agent Date: Fri, 23 Jan 2026 20:34:00 +0000 Subject: [PATCH] Fix iCal endpoint crash from non-ASCII characters in workspace name The Content-Disposition header was including the workspace name directly, causing a "Cannot convert argument to ByteString" error when workspace names contained smart apostrophes or other non-ASCII characters (e.g., "Grace's Plan" with curly apostrophe U+2019). Sanitize filename by removing non-ASCII characters before using in header. Co-Authored-By: Claude Opus 4.5 --- src/app/api/workspaces/[id]/calendar.ics/route.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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', }, })