Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Baarsen <jeroenvanbaarsen@gmail.com>2014-02-13 23:09:11 +0400
committerJeroen van Baarsen <jeroenvanbaarsen@gmail.com>2014-02-13 23:09:11 +0400
commitaaad7fd973d88a49fe23f01cca6b2248ad7977d4 (patch)
treea6b1ac86235ff0b503e9e7d521b6f6e879b4317b /app/controllers/projects/raw_controller.rb
parentd41e404e09c79394ff1938eee01b56345edc6ed9 (diff)
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
Diffstat (limited to 'app/controllers/projects/raw_controller.rb')
-rw-r--r--app/controllers/projects/raw_controller.rb18
1 files changed, 13 insertions, 5 deletions
diff --git a/app/controllers/projects/raw_controller.rb b/app/controllers/projects/raw_controller.rb
index 18ace028b0c..a6b7ae3f127 100644
--- a/app/controllers/projects/raw_controller.rb
+++ b/app/controllers/projects/raw_controller.rb
@@ -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