Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unsafe hotserving behaviour for multimedia uploads. #3113

Merged
merged 3 commits into from
Jun 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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