Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-06-27 23:08:39 +0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-07-06 02:57:09 +0300
commitd6b60e83edb755347c56e38770fcdffab9edbfa0 (patch)
treea1fe24959d98ea3220214f9afe2a4050fdafd17d /app
parentab811b6ab929d3f220e060c15c49bc075d91e5f2 (diff)
Move `unescape_html_entities` from LabelsHelper to Label model
Diffstat (limited to 'app')
-rw-r--r--app/helpers/labels_helper.rb12
-rw-r--r--app/models/label.rb12
2 files changed, 12 insertions, 12 deletions
diff --git a/app/helpers/labels_helper.rb b/app/helpers/labels_helper.rb
index 1f0d5d545c0..5e9f5837101 100644
--- a/app/helpers/labels_helper.rb
+++ b/app/helpers/labels_helper.rb
@@ -1,12 +1,6 @@
module LabelsHelper
include ActionView::Helpers::TagHelper
- TABLE_FOR_ESCAPE_HTML_ENTITIES = {
- '&' => '&amp;',
- '<' => '&lt;',
- '>' => '&gt;'
- }
-
# Link to a Label
#
# label - Label object to link to
@@ -136,11 +130,7 @@ module LabelsHelper
label.subscribed?(current_user) ? 'Unsubscribe' : 'Subscribe'
end
- def unescape_html_entities(value)
- value.to_s.gsub(/(&gt;)|(&lt;)|(&amp;)/, TABLE_FOR_ESCAPE_HTML_ENTITIES.invert)
- end
-
# Required for Banzai::Filter::LabelReferenceFilter
module_function :render_colored_label, :render_colored_cross_project_label,
- :text_color_for_bg, :escape_once, :unescape_html_entities
+ :text_color_for_bg, :escape_once
end
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