Commit aaad7fd9 authored by Jeroen van Baarsen's avatar Jeroen van Baarsen

Fixes #6207 Allow raw download of *.msi files

This PR also allows for download of [exe,rar,r0n,7z,7zip,zip]
Fix was originaly proposed by @MensSana
parent d41e404e
...@@ -11,11 +11,7 @@ class Projects::RawController < Projects::ApplicationController ...@@ -11,11 +11,7 @@ class Projects::RawController < Projects::ApplicationController
@blob = @repository.blob_at(@commit.id, @path) @blob = @repository.blob_at(@commit.id, @path)
if @blob if @blob
type = if @blob.mime_type =~ /html|javascript/ type = get_blob_type
'text/plain; charset=utf-8'
else
@blob.mime_type
end
headers['X-Content-Type-Options'] = 'nosniff' headers['X-Content-Type-Options'] = 'nosniff'
...@@ -29,5 +25,17 @@ class Projects::RawController < Projects::ApplicationController ...@@ -29,5 +25,17 @@ class Projects::RawController < Projects::ApplicationController
not_found! not_found!
end end
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 end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment