Commit d4180875 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Merge branch 'fix-xss' into 'master'

Fix XSS issue

When view blob as RAW make sure we allow only 2 kind of type: 'text/plain' and 'application/octet-stream'

Fixes #1514

See merge request !1045
parents 3069826d 6f154c07
......@@ -29,12 +29,10 @@ class Projects::RawController < Projects::ApplicationController
private
def get_blob_type
if @blob.mime_type =~ /html|javascript/
if @blob.text?
'text/plain; charset=utf-8'
elsif @blob.name =~ /(?:msi|exe|rar|r0\d|7z|7zip|zip)$/
'application/octet-stream'
else
@blob.mime_type
'application/octet-stream'
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