Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
Fix unsafe hotserving behaviour for multimedia uploads. (#3113)
Browse files Browse the repository at this point in the history
Return multimedia with a disposition type of attachment instead of
inline. NVT#1548992

Signed-off-by: Josh Qou [jqou@icloud.com](mailto:jqou@icloud.com)

Co-authored-by: Jon <haddock.05.roast@icloud.com>
  • Loading branch information
joshqou and Jon authored Jun 15, 2023
1 parent 8cf6c38 commit 420e7ec
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mediaapi/routing/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ func (r *downloadRequest) addDownloadFilenameToHeaders(
}

if len(filename) == 0 {
w.Header().Set("Content-Disposition", "attachment")
return nil
}

Expand Down Expand Up @@ -376,13 +377,13 @@ func (r *downloadRequest) addDownloadFilenameToHeaders(
// that would otherwise be parsed as a control character in the
// Content-Disposition header
w.Header().Set("Content-Disposition", fmt.Sprintf(
`inline; filename=%s%s%s`,
`attachment; filename=%s%s%s`,
quote, unescaped, quote,
))
} else {
// For UTF-8 filenames, we quote always, as that's the standard
w.Header().Set("Content-Disposition", fmt.Sprintf(
`inline; filename*=utf-8''%s`,
`attachment; filename*=utf-8''%s`,
url.QueryEscape(unescaped),
))
}
Expand Down

0 comments on commit 420e7ec

Please sign in to comment.