Fix XSS vulnerability in protocol keywords [SCI-632]

This commit is contained in:
Oleksii Kriuchykhin 2016-12-29 15:15:29 +01:00
parent 4b50c73474
commit d798f1b120
2 changed files with 6 additions and 2 deletions

View file

@ -159,6 +159,10 @@ class ProtocolsController < ApplicationController
def update_keywords
respond_to do |format|
# sanitize user input
params[:keywords].collect! do |keyword|
ActionController::Base.helpers.sanitize(keyword)
end
if @protocol.update_keywords(params[:keywords])
format.json {
render json: {

View file

@ -1,5 +1,5 @@
<% if @protocol.protocol_keywords.count > 0 %>
<%= @protocol.protocol_keywords.collect{ |kw| "<strong>#{kw.name}</strong>" }.join(", ").html_safe %>
<%= @protocol.protocol_keywords.collect{ |kw| "<strong>#{sanitize(kw.name)}</strong>" }.join(", ").html_safe %>
<% else %>
<em><%= t("protocols.no_keywords") %></em>
<% end %>
<% end %>