Commit 6f0126385d04b4d19df7453fc2bd69f1ae8c3f25

Authored by Dmitriy Zaporozhets
2 parents 767c39a3 aaad7fd9

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

Fixes #6207 Allow raw download of *.msi files
Showing 1 changed file with 13 additions and 5 deletions   Show diff stats
app/controllers/projects/raw_controller.rb
... ... @@ -11,11 +11,7 @@ class Projects::RawController < Projects::ApplicationController
11 11 @blob = @repository.blob_at(@commit.id, @path)
12 12  
13 13 if @blob
14   - type = if @blob.mime_type =~ /html|javascript/
15   - 'text/plain; charset=utf-8'
16   - else
17   - @blob.mime_type
18   - end
  14 + type = get_blob_type
19 15  
20 16 headers['X-Content-Type-Options'] = 'nosniff'
21 17  
... ... @@ -29,5 +25,17 @@ class Projects::RawController < Projects::ApplicationController
29 25 not_found!
30 26 end
31 27 end
  28 +
  29 + private
  30 +
  31 + def get_blob_type
  32 + if @blob.mime_type =~ /html|javascript/
  33 + 'text/plain; charset=utf-8'
  34 + elsif @blob.name =~ /(?:msi|exe|rar|r0\d|7z|7zip|zip)$/
  35 + 'application/octet-stream'
  36 + else
  37 + @blob.mime_type
  38 + end
  39 + end
32 40 end
33 41  
... ...