Dont allow html render for RAW view

This commit is contained in:
Dmitriy Zaporozhets 2013-09-03 20:55:01 +03:00
parent 1de270c9e0
commit 38cebe03bc

View file

@ -11,9 +11,17 @@ class Projects::RawController < Projects::ApplicationController
@blob = Gitlab::Git::Blob.new(@repository, @commit.id, @ref, @path)
if @blob.exists?
type = if @blob.mime_type =~ /html|javascript/
'text/plain; charset=utf-8'
else
@blob.mime_type
end
headers['X-Content-Type-Options'] = 'nosniff'
send_data(
@blob.data,
type: @blob.mime_type,
type: type,
disposition: 'inline',
filename: @blob.name
)