Skip to content

A continuation of HomeBox the inventory and organization system built for the Home User

Escape file name for content-disposition.

Matthew Kilgore04c8e38ecffc
diff --git a/backend/app/api/handlers/v1/v1_ctrl_items_attachments.go b/backend/app/api/handlers/v1/v1_ctrl_items_attachments.go
index 9e303e72..bd1bf633 100644
--- a/backend/app/api/handlers/v1/v1_ctrl_items_attachments.go
+++ b/backend/app/api/handlers/v1/v1_ctrl_items_attachments.go
@@ -3,6 +3,7 @@ package v1
import (
"errors"
"net/http"
+ "net/url"
"path/filepath"
"strconv"
"strings"
@@ -203,7 +204,9 @@ func (ctrl *V1Controller) handleItemAttachmentsHandler(w http.ResponseWriter, r
}
}(bucket)
- w.Header().Set("Content-Disposition", "attachment; filename="+doc.Title)
+ // Set the Content-Disposition header for RFC6266 compliance
+ disposition := "attachment; filename*=UTF-8''" + url.QueryEscape(doc.Title)
+ w.Header().Set("Content-Disposition", disposition)
http.ServeContent(w, r, doc.Title, doc.CreatedAt, file)
return nil