diff --git a/app/helpers/activity_helper.rb b/app/helpers/activity_helper.rb
index 659b222ab..04d1d492d 100644
--- a/app/helpers/activity_helper.rb
+++ b/app/helpers/activity_helper.rb
@@ -8,6 +8,6 @@ module ActivityHelper
title = truncate(activity_title, length: len)
end
message = message.gsub(/#{activity_title}/, title )
- message.html_safe if message
+ sanitize_input(message.html_safe) if message
end
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 31990a632..eaa1d5e40 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -14,8 +14,10 @@ module ApplicationHelper
def display_tooltip(message, len = Constants::NAME_TRUNCATION_LENGTH)
if message.strip.length > Constants::NAME_TRUNCATION_LENGTH
- "
#{truncate(message.strip, length: len)} \
- #{message.strip}
".html_safe
+ sanitize_input(" \
+ #{truncate(message.strip, length: len)} \
+ \
+ #{message.strip}
")
else
truncate(message.strip, length: len)
end
diff --git a/app/helpers/assets_helper.rb b/app/helpers/assets_helper.rb
index 404819241..7db281e88 100644
--- a/app/helpers/assets_helper.rb
+++ b/app/helpers/assets_helper.rb
@@ -4,7 +4,7 @@ module AssetsHelper
res = <<-eos
len
- "#{truncate(name, length: len)}
- #{name}
".html_safe
+ "#{truncate(sanitize_input(name), length: len)}
+ #{sanitize_input(name)}
+
".html_safe
else
name
end
diff --git a/app/helpers/protocol_status_helper.rb b/app/helpers/protocol_status_helper.rb
index 855246ca4..e0645a686 100644
--- a/app/helpers/protocol_status_helper.rb
+++ b/app/helpers/protocol_status_helper.rb
@@ -5,7 +5,10 @@ module ProtocolStatusHelper
res = ""
res << "" + protocol_name(parent) + ""
+ res << sanitize_input(protocol_status_popover_title(parent)) +
+ '" data-content="' +
+ sanitize_input(protocol_status_popover_content(parent)) +
+ '">' + sanitize_input(protocol_name(parent)) + ''
res.html_safe
end
diff --git a/app/views/my_modules/activities/_activity.html.erb b/app/views/my_modules/activities/_activity.html.erb
index f5d261aaa..63a047b90 100644
--- a/app/views/my_modules/activities/_activity.html.erb
+++ b/app/views/my_modules/activities/_activity.html.erb
@@ -2,6 +2,6 @@
<%= l activity.created_at, format: :full %>
- <%= activity.message.html_safe %>
+ <%= sanitize_input(activity.message) %>
-
\ No newline at end of file
+
diff --git a/app/views/reports/elements/_my_module_activity_element.html.erb b/app/views/reports/elements/_my_module_activity_element.html.erb
index 4582d0868..a0a47a563 100644
--- a/app/views/reports/elements/_my_module_activity_element.html.erb
+++ b/app/views/reports/elements/_my_module_activity_element.html.erb
@@ -30,7 +30,7 @@
- <%= activity.message.html_safe %>
+ <%= sanitize_input(activity.message) %>
<% end %>
diff --git a/config/initializers/constants.rb b/config/initializers/constants.rb
index 91ff85752..7940dd3bc 100644
--- a/config/initializers/constants.rb
+++ b/config/initializers/constants.rb
@@ -207,6 +207,11 @@ class Constants
'gif', 'jpeg', 'pjpeg', 'png', 'x-png', 'svg+xml', 'bmp'
].freeze
+ WHITELISTED_TAGS = [
+ 'a', 'b', 'strong', 'i', 'em', 'li', 'ul', 'ol', 'h1',
+ 'h2', 'h3', 'br', 'sub', 'p', 'div', 'span'
+ ].freeze
+
# Very basic regex to check for validity of emails
BASIC_EMAIL_REGEX = URI::MailTo::EMAIL_REGEXP