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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
a1d69ab6
Commit
a1d69ab6
authored
Dec 12, 2018
by
Jarka Košanová
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Escape html entities when no label found
parent
7b1ea8ca
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
1 deletion
+28
-1
changelogs/unreleased/54427-label-xss.yml
changelogs/unreleased/54427-label-xss.yml
+5
-0
lib/banzai/filter/label_reference_filter.rb
lib/banzai/filter/label_reference_filter.rb
+5
-1
spec/lib/banzai/filter/label_reference_filter_spec.rb
spec/lib/banzai/filter/label_reference_filter_spec.rb
+18
-0
No files found.
changelogs/unreleased/54427-label-xss.yml
0 → 100644
View file @
a1d69ab6
---
title
:
Escape html entities in LabelReferenceFilter when no label found
merge_request
:
author
:
type
:
security
lib/banzai/filter/label_reference_filter.rb
View file @
a1d69ab6
...
@@ -29,7 +29,7 @@ module Banzai
...
@@ -29,7 +29,7 @@ module Banzai
if
label
if
label
yield
match
,
label
.
id
,
project
,
namespace
,
$~
yield
match
,
label
.
id
,
project
,
namespace
,
$~
else
else
match
escape_html_entities
(
match
)
end
end
end
end
end
end
...
@@ -102,6 +102,10 @@ module Banzai
...
@@ -102,6 +102,10 @@ module Banzai
CGI
.
unescapeHTML
(
text
.
to_s
)
CGI
.
unescapeHTML
(
text
.
to_s
)
end
end
def
escape_html_entities
(
text
)
CGI
.
escapeHTML
(
text
.
to_s
)
end
def
object_link_title
(
object
,
matches
)
def
object_link_title
(
object
,
matches
)
# use title of wrapped element instead
# use title of wrapped element instead
nil
nil
...
...
spec/lib/banzai/filter/label_reference_filter_spec.rb
View file @
a1d69ab6
...
@@ -236,6 +236,24 @@ describe Banzai::Filter::LabelReferenceFilter do
...
@@ -236,6 +236,24 @@ describe Banzai::Filter::LabelReferenceFilter do
end
end
end
end
context
'References with html entities'
do
let!
(
:label
)
{
create
(
:label
,
name:
'<html>'
,
project:
project
)
}
it
'links to a valid reference'
do
doc
=
reference_filter
(
'See ~"<html>"'
)
expect
(
doc
.
css
(
'a'
).
first
.
attr
(
'href'
)).
to
eq
urls
.
project_issues_url
(
project
,
label_name:
label
.
name
)
expect
(
doc
.
text
).
to
eq
'See <html>'
end
it
'ignores invalid label names and escapes entities'
do
act
=
%(Label #{Label.reference_prefix}"<non valid>")
expect
(
reference_filter
(
act
).
to_html
).
to
eq
act
end
end
describe
'consecutive references'
do
describe
'consecutive references'
do
let
(
:bug
)
{
create
(
:label
,
name:
'bug'
,
project:
project
)
}
let
(
:bug
)
{
create
(
:label
,
name:
'bug'
,
project:
project
)
}
let
(
:feature_proposal
)
{
create
(
:label
,
name:
'feature proposal'
,
project:
project
)
}
let
(
:feature_proposal
)
{
create
(
:label
,
name:
'feature proposal'
,
project:
project
)
}
...
...
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