fix(files): RFC 5987 encode Content-Disposition filenames#4713
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview Exports Reviewed by Cursor Bugbot for commit c1f04ed. Configure here. |
Greptile SummaryThis PR fixes a production 500 error on
Confidence Score: 5/5Safe to merge — the change is narrow, touches only Content-Disposition header construction, and uses a battle-tested helper that was already in production for the file-serve path. All four callsites are correctly updated. The remaining Content-Disposition callsites in the codebase either use hardcoded ASCII filenames, apply a sanitizer that strips non-ASCII before header construction, or have their own inline RFC 5987 encoding — none are left in a broken state. The encoding logic itself (percent-encoding via encodeURIComponent with an ASCII fallback) is correct for RFC 5987. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant ExportRoute as files/export/[id]
participant AdminRoute as admin/folders or workspaces export
participant Utils as encodeFilenameForHeader
Client->>ExportRoute: GET file with non-ASCII name
ExportRoute->>Utils: encodeFilenameForHeader(mdName)
Utils-->>ExportRoute: RFC 5987 encoded header value
ExportRoute-->>Client: 200 with valid Content-Disposition
Client->>AdminRoute: GET folder or workspace with Unicode name
AdminRoute->>AdminRoute: sanitizePathSegment keeps Unicode letters
AdminRoute->>Utils: encodeFilenameForHeader(filename)
Utils-->>AdminRoute: RFC 5987 encoded header value
AdminRoute-->>Client: 200 with valid Content-Disposition
Reviews (1): Last reviewed commit: "fix(files): RFC 5987 encode Content-Disp..." | Re-trigger Greptile |
Summary
—) returned 500 from/api/files/export/[id]because theContent-Dispositionheader value isn't valid ISO-8859-1encodeFilenameForHeaderhelper (RFC 5987filename=...; filename*=UTF-8''...); also fixed admin folder/workspace ZIP exports which usedsanitizePathSegment(keeps Unicode letters) and had the same latent bugType of Change
Testing
Tested manually — reproduced the 500 in prod logs (
Header '17' has invalid value: 'attachment; filename="Linear Pagination Loop — Reference.md"'), audited everyContent-Dispositioncallsite in the app, fixed only the ones whose filename source can contain non-ASCIIChecklist