From 8e41a523762c4919e2894217cb1a280c4fcefdef Mon Sep 17 00:00:00 2001 From: Mario Squeo <6081892+msquee@users.noreply.github.com> Date: Tue, 29 Jun 2021 12:03:52 -0400 Subject: [PATCH] Fix files preview. Set charset=utf-8 in Content-Type header (#1254) * Fix files preview. Set charset=utf-8 in Content-Type header * Render text formats as text/plain --- apps/dashboard/app/models/files.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/dashboard/app/models/files.rb b/apps/dashboard/app/models/files.rb index 8234f9a12c..f513bc50c0 100644 --- a/apps/dashboard/app/models/files.rb +++ b/apps/dashboard/app/models/files.rb @@ -132,11 +132,10 @@ def self.mime_type_for_preview(type) # x === 'application/x-yaml' # # => true # - case type - when 'text/javascript', 'text/css', 'text/yaml', 'text/yml' - 'text/plain' - else + if %r{text/.*}.match(type).nil? type + else + 'text/plain; charset=utf-8' end end