Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
d6b60e83
Commit
d6b60e83
authored
Jun 27, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move `unescape_html_entities` from LabelsHelper to Label model
parent
ab811b6a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
19 deletions
+13
-19
app/helpers/labels_helper.rb
app/helpers/labels_helper.rb
+1
-11
app/models/label.rb
app/models/label.rb
+11
-1
lib/banzai/filter/label_reference_filter.rb
lib/banzai/filter/label_reference_filter.rb
+1
-1
spec/helpers/labels_helper_spec.rb
spec/helpers/labels_helper_spec.rb
+0
-6
No files found.
app/helpers/labels_helper.rb
View file @
d6b60e83
module
LabelsHelper
include
ActionView
::
Helpers
::
TagHelper
TABLE_FOR_ESCAPE_HTML_ENTITIES
=
{
'&'
=>
'&'
,
'<'
=>
'<'
,
'>'
=>
'>'
}
# 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
(
/(>)|(<)|(&)/
,
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
app/models/label.rb
View file @
d6b60e83
...
...
@@ -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
lib/banzai/filter/label_reference_filter.rb
View file @
d6b60e83
...
...
@@ -68,7 +68,7 @@ module Banzai
end
def
unescape_html_entities
(
text
)
LabelsHelper
.
unescape_html_entities
(
tex
t
)
text
.
to_s
.
gsub
(
/(>)|(<)|(&)/
,
Label
::
TABLE_FOR_ESCAPE_HTML_ENTITIES
.
inver
t
)
end
end
end
...
...
spec/helpers/labels_helper_spec.rb
View file @
d6b60e83
...
...
@@ -77,10 +77,4 @@ describe LabelsHelper do
expect
(
text_color_for_bg
(
'#000'
)).
to
eq
'#FFFFFF'
end
end
describe
'unescape_html_entities'
do
it
'decodes &, <, and > named entities'
do
expect
(
unescape_html_entities
(
'foo & bar < zoo > boo é'
)).
to
eq
'foo & bar < zoo > boo é'
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment