Skip to content
Snippets Groups Projects
Commit 77ec2354 authored by Travis Ralston's avatar Travis Ralston
Browse files

Fix Content-Disposition handling

parent 081a53ae
No related branches found
No related tags found
No related merge requests found
......@@ -112,7 +112,7 @@ beforeParseDownload:
if contentType == "" {
disposition = "attachment"
} else {
if util.HasAnyPrefix(contentType, []string{"image/", "audio/", "video/", "text/plain"}) {
if util.CanInline(contentType) {
disposition = "inline"
} else {
disposition = "attachment"
......
......@@ -16,3 +16,39 @@ func ExtensionForContentType(ct string) string {
}
return ".bin"
}
func CanInline(ct string) bool {
ct = FixContentType(ct)
return ArrayContains(InlineContentTypes, ct)
}
var InlineContentTypes = []string{
// Types are inherited from https://github.com/matrix-org/synapse/pull/15988
"text/css",
"text/plain",
"text/csv",
"application/json",
"application/ld+json",
"image/jpeg",
"image/gif",
"image/png",
"image/apng",
"image/webp",
"image/avif",
"video/mp4",
"video/webm",
"video/ogg",
"video/quicktime",
"audio/mp4",
"audio/webm",
"audio/aac",
"audio/mpeg",
"audio/ogg",
"audio/wave",
"audio/wav",
"audio/x-wav",
"audio/x-pn-wav",
"audio/flac",
"audio/x-flac",
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment