check file types with lowercase

This commit is contained in:
Kyle Drake 2014-03-27 23:38:57 -07:00
parent 5884b6aaaa
commit fdd4017523

2
app.rb
View file

@ -307,7 +307,7 @@ post '/site_files/upload' do
mime_type = Magic.guess_file_mime_type params[:newfile][:tempfile].path mime_type = Magic.guess_file_mime_type params[:newfile][:tempfile].path
unless (Site::VALID_MIME_TYPES.include?(mime_type) || mime_type =~ /text/) && Site::VALID_EXTENSIONS.include?(File.extname(params[:newfile][:filename]).sub(/^./, '')) unless (Site::VALID_MIME_TYPES.include?(mime_type) || mime_type =~ /text/) && Site::VALID_EXTENSIONS.include?(File.extname(params[:newfile][:filename]).sub(/^./, '').downcase)
@errors << 'File must me one of the following: HTML, Text, Image (JPG PNG GIF JPEG SVG), JS, CSS, Markdown.' @errors << 'File must me one of the following: HTML, Text, Image (JPG PNG GIF JPEG SVG), JS, CSS, Markdown.'
halt http_error_code, 'File type is not supported.' # slim(:'site_files/new') halt http_error_code, 'File type is not supported.' # slim(:'site_files/new')
end end