summaryrefslogtreecommitdiff
path: root/app/models/label.rb
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-06-27 17:08:39 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-07-05 20:57:09 -0300
commitd6b60e83edb755347c56e38770fcdffab9edbfa0 (patch)
treea1fe24959d98ea3220214f9afe2a4050fdafd17d /app/models/label.rb
parentab811b6ab929d3f220e060c15c49bc075d91e5f2 (diff)
downloadgitlab-ce-d6b60e83edb755347c56e38770fcdffab9edbfa0.tar.gz
Move `unescape_html_entities` from LabelsHelper to Label model
Diffstat (limited to 'app/models/label.rb')
-rw-r--r--app/models/label.rb12
1 files changed, 11 insertions, 1 deletions
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 = {
+ '&' => '&amp;',
+ '<' => '&lt;',
+ '>' => '&gt;'
+ }
+
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(/(&gt;)|(&lt;)|(&amp;)/, TABLE_FOR_ESCAPE_HTML_ENTITIES.invert)
end
end