Dont allow html render for RAW view
This commit is contained in:
parent
1de270c9e0
commit
38cebe03bc
1 changed files with 9 additions and 1 deletions
|
@ -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
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue