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
23517b61
Commit
23517b61
authored
Jul 15, 2019
by
Patrick Derichs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix HTML injection for label description
parent
01e37ab6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
3 deletions
+29
-3
app/helpers/labels_helper.rb
app/helpers/labels_helper.rb
+1
-1
app/models/label.rb
app/models/label.rb
+6
-2
changelogs/unreleased/security-fix-html-injection-for-label-description-ce-master.yml
...ty-fix-html-injection-for-label-description-ce-master.yml
+5
-0
spec/helpers/labels_helper_spec.rb
spec/helpers/labels_helper_spec.rb
+10
-0
spec/models/label_spec.rb
spec/models/label_spec.rb
+7
-0
No files found.
app/helpers/labels_helper.rb
View file @
23517b61
...
...
@@ -71,7 +71,7 @@ module LabelsHelper
end
def
label_tooltip_title
(
label
)
label
.
description
Sanitize
.
clean
(
label
.
description
)
end
def
suggested_colors
...
...
app/models/label.rb
View file @
23517b61
...
...
@@ -197,7 +197,11 @@ class Label < ApplicationRecord
end
def
title
=
(
value
)
write_attribute
(
:title
,
sanitize_title
(
value
))
if
value
.
present?
write_attribute
(
:title
,
sanitize_value
(
value
))
if
value
.
present?
end
def
description
=
(
value
)
write_attribute
(
:description
,
sanitize_value
(
value
))
if
value
.
present?
end
##
...
...
@@ -258,7 +262,7 @@ class Label < ApplicationRecord
end
end
def
sanitize_
titl
e
(
value
)
def
sanitize_
valu
e
(
value
)
CGI
.
unescapeHTML
(
Sanitize
.
clean
(
value
.
to_s
))
end
...
...
changelogs/unreleased/security-fix-html-injection-for-label-description-ce-master.yml
0 → 100644
View file @
23517b61
---
title
:
Fix HTML injection for label description
merge_request
:
author
:
type
:
security
spec/helpers/labels_helper_spec.rb
View file @
23517b61
...
...
@@ -278,4 +278,14 @@ describe LabelsHelper do
it
{
is_expected
.
to
eq
(
'Subscribe at group level'
)
}
end
end
describe
'#label_tooltip_title'
do
let
(
:html
)
{
'<img src="example.png">This is an image</img>'
}
let
(
:label_with_html_content
)
{
create
(
:label
,
title:
'test'
,
description:
html
)
}
it
'removes HTML'
do
tooltip
=
label_tooltip_title
(
label_with_html_content
)
expect
(
tooltip
).
to
eq
(
'This is an image'
)
end
end
end
spec/models/label_spec.rb
View file @
23517b61
...
...
@@ -84,6 +84,13 @@ describe Label do
end
end
describe
'#description'
do
it
'sanitizes description'
do
label
=
described_class
.
new
(
description:
'<b>foo & bar?</b>'
)
expect
(
label
.
description
).
to
eq
(
'foo & bar?'
)
end
end
describe
'priorization'
do
subject
(
:label
)
{
create
(
:label
)
}
...
...
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