Add the content type for external URLs

This commit is contained in:
Oliver Günther
2026-05-29 10:25:20 +02:00
parent 6f63faeed1
commit 5330745e69
4 changed files with 42 additions and 24 deletions
+1 -11
View File
@@ -100,17 +100,7 @@ module API
end
def attachment_content_type(attachment)
if attachment.is_text?
# Even if the text mime type might differ, always output plain text
# so this doesn't get interpreted as e.g., a script or html file
charset = attachment.charset.presence || Setting.attachment_default_charset
"text/plain; charset=#{charset}"
elsif attachment.inlineable?
attachment.content_type
else
# For security reasons, mark all non-inlinable files as an octet-stream first
"application/octet-stream"
end
attachment.served_content_type
end
def set_cache_headers