提交 6f012638 编写于 作者: D Dmitriy Zaporozhets

Merge pull request #6313 from jvanbaarsen/fix-6207-msi-mimetype

Fixes #6207 Allow raw download of *.msi files
......@@ -11,11 +11,7 @@ class Projects::RawController < Projects::ApplicationController
@blob = @repository.blob_at(@commit.id, @path)
if @blob
type = if @blob.mime_type =~ /html|javascript/
'text/plain; charset=utf-8'
else
@blob.mime_type
end
type = get_blob_type
headers['X-Content-Type-Options'] = 'nosniff'
......@@ -29,5 +25,17 @@ class Projects::RawController < Projects::ApplicationController
not_found!
end
end
private
def get_blob_type
if @blob.mime_type =~ /html|javascript/
'text/plain; charset=utf-8'
elsif @blob.name =~ /(?:msi|exe|rar|r0\d|7z|7zip|zip)$/
'application/octet-stream'
else
@blob.mime_type
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册