From 329c07f24b27b0238aa0bd02ae9b4003b13387d4 Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 24 Feb 2026 20:38:40 +0100 Subject: [PATCH] fix(attachments): use mime.FormatMediaType for Content-Disposition header --- pkg/routes/api/v1/task_attachment.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/routes/api/v1/task_attachment.go b/pkg/routes/api/v1/task_attachment.go index cefce0243..0bb10c903 100644 --- a/pkg/routes/api/v1/task_attachment.go +++ b/pkg/routes/api/v1/task_attachment.go @@ -19,6 +19,7 @@ package v1 import ( "errors" "io" + "mime" "net/http" "strconv" "strings" @@ -210,9 +211,9 @@ func GetTaskAttachment(c *echo.Context) error { mimeToReturn = "application/octet-stream" } - filename := strings.ReplaceAll(taskAttachment.File.Name, `"`, `\"`) - - c.Response().Header().Set("Content-Disposition", "attachment; filename=\""+filename+"\"") + c.Response().Header().Set("Content-Disposition", mime.FormatMediaType("attachment", map[string]string{ + "filename": taskAttachment.File.Name, + })) c.Response().Header().Set("Content-Type", mimeToReturn) c.Response().Header().Set("Content-Length", strconv.FormatUint(taskAttachment.File.Size, 10)) c.Response().Header().Set("Last-Modified", taskAttachment.File.Created.UTC().Format(http.TimeFormat))