Skip to content

Commit

Permalink
missing filename escapes in flash messages
Browse files Browse the repository at this point in the history
  • Loading branch information
kyledrake committed May 7, 2020
1 parent c6a83f8 commit 7b0df67
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/site_files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def require_login_file_upload_ajax

file[:filename] = "#{dir_name}/#{site.scrubbed_path file[:filename]}"
if current_site.file_size_too_large? file[:tempfile].size
file_upload_response "#{file[:filename]} is too large, upload cancelled."
file_upload_response "#{Rack::Utils.escape_html file[:filename]} is too large, upload cancelled."
end
if !site.okay_to_upload? file
file_upload_response %{#{Rack::Utils.escape_html file[:filename]}: file type (or content in file) is only supported by <a href="/supporter">supporter accounts</a>. <a href="/site_files/allowed_types">Why We Do This</a>}
Expand All @@ -157,7 +157,7 @@ def require_login_file_upload_ajax
require_login
path = HTMLEntities.new.decode params[:filename]
current_site.delete_file path
flash[:success] = "Deleted #{params[:filename]}."
flash[:success] = "Deleted #{Rack::Utils.escape_html params[:filename]}."

dirname = Pathname(path).dirname
dir_query = dirname.nil? || dirname.to_s == '.' ? '' : "?dir=#{Rack::Utils.escape dirname}"
Expand All @@ -174,9 +174,9 @@ def require_login_file_upload_ajax
res = site_file.rename new_path

if res.first == true
flash[:success] = "Renamed #{path} to #{new_path}"
flash[:success] = "Renamed #{Rack::Utils.escape_html path} to #{Rack::Utils.escape_html new_path}"
else
flash[:error] = "Failed to rename #{path} to #{new_path}: #{res.last}"
flash[:error] = "Failed to rename #{Rack::Utils.escape_html path} to #{Rack::Utils.escape_html new_path}: #{Rack::Utils.escape_html res.last}"
end

dirname = Pathname(path).dirname
Expand Down

0 comments on commit 7b0df67

Please sign in to comment.