Use CGI.unescapeHTML rather than doing the gsub with a map

parent d6b60e83
...@@ -10,12 +10,6 @@ class Label < ActiveRecord::Base ...@@ -10,12 +10,6 @@ class Label < ActiveRecord::Base
DEFAULT_COLOR = '#428BCA' DEFAULT_COLOR = '#428BCA'
TABLE_FOR_ESCAPE_HTML_ENTITIES = {
'&' => '&amp;',
'<' => '&lt;',
'>' => '&gt;'
}
default_value_for :color, DEFAULT_COLOR default_value_for :color, DEFAULT_COLOR
belongs_to :project belongs_to :project
...@@ -140,10 +134,6 @@ class Label < ActiveRecord::Base ...@@ -140,10 +134,6 @@ class Label < ActiveRecord::Base
end end
def sanitize_title(value) def sanitize_title(value)
unescape_html_entities(Sanitize.clean(value.to_s)) CGI.unescapeHTML(Sanitize.clean(value.to_s))
end
def unescape_html_entities(value)
value.to_s.gsub(/(&gt;)|(&lt;)|(&amp;)/, TABLE_FOR_ESCAPE_HTML_ENTITIES.invert)
end end
end end
...@@ -68,7 +68,7 @@ module Banzai ...@@ -68,7 +68,7 @@ module Banzai
end end
def unescape_html_entities(text) def unescape_html_entities(text)
text.to_s.gsub(/(&gt;)|(&lt;)|(&amp;)/, Label::TABLE_FOR_ESCAPE_HTML_ENTITIES.invert) CGI.unescapeHTML(text.to_s)
end end
end end
end 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