Commit 118bd717 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Sanitize snippet file name in raw headers

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent f28a12a5
......@@ -68,7 +68,7 @@ class Projects::SnippetsController < Projects::ApplicationController
@snippet.content,
type: 'text/plain; charset=utf-8',
disposition: 'inline',
filename: @snippet.file_name
filename: @snippet.sanitized_file_name
)
end
......
......@@ -79,7 +79,7 @@ class SnippetsController < ApplicationController
@snippet.content,
type: 'text/plain; charset=utf-8',
disposition: 'inline',
filename: @snippet.file_name
filename: @snippet.sanitized_file_name
)
end
......
......@@ -64,6 +64,10 @@ class Snippet < ActiveRecord::Base
file_name
end
def sanitized_file_name
file_name.gsub(/[^a-zA-Z0-9_\-\.]+/, '')
end
def mode
nil
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