Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion apps/api/internal/handler/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ func (h *UploadHandler) ServeFile(c *gin.Context) {

c.Header("Content-Type", info.ContentType)
c.Header("X-Content-Type-Options", "nosniff")
c.Header("Content-Disposition", "inline")
// Attachments are arbitrary user files with an unvalidated content-type, so
// force a download instead of rendering them inline: an uploaded .html or
// SVG would otherwise execute on the API origin when opened. The uploads/
// prefix (avatars, covers, logos) is validated as images and stays inline.
disposition := "inline"
if strings.HasPrefix(path, "attachments/") {
disposition = "attachment"
}
c.Header("Content-Disposition", disposition)
c.DataFromReader(http.StatusOK, info.Size, info.ContentType, obj, nil)
}
Loading