From d6b60e83edb755347c56e38770fcdffab9edbfa0 Mon Sep 17 00:00:00 2001 From: Douglas Barbosa Alexandre Date: Mon, 27 Jun 2016 17:08:39 -0300 Subject: Move `unescape_html_entities` from LabelsHelper to Label model --- app/models/label.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'app/models/label.rb') diff --git a/app/models/label.rb b/app/models/label.rb index 086007d1864..b0e2cb448b8 100644 --- a/app/models/label.rb +++ b/app/models/label.rb @@ -10,6 +10,12 @@ class Label < ActiveRecord::Base DEFAULT_COLOR = '#428BCA' + TABLE_FOR_ESCAPE_HTML_ENTITIES = { + '&' => '&', + '<' => '<', + '>' => '>' + } + default_value_for :color, DEFAULT_COLOR belongs_to :project @@ -134,6 +140,10 @@ class Label < ActiveRecord::Base end def sanitize_title(value) - LabelsHelper.unescape_html_entities(Sanitize.clean(value.to_s)) + unescape_html_entities(Sanitize.clean(value.to_s)) + end + + def unescape_html_entities(value) + value.to_s.gsub(/(>)|(<)|(&)/, TABLE_FOR_ESCAPE_HTML_ENTITIES.invert) end end -- cgit v1.2.3