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
a0930b83
Commit
a0930b83
authored
Jul 16, 2018
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Escapes milestone and label names when promoting them
parent
fc9f9004
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
5 deletions
+30
-5
app/controllers/projects/labels_controller.rb
app/controllers/projects/labels_controller.rb
+10
-1
app/controllers/projects/milestones_controller.rb
app/controllers/projects/milestones_controller.rb
+11
-3
spec/controllers/projects/labels_controller_spec.rb
spec/controllers/projects/labels_controller_spec.rb
+8
-0
spec/controllers/projects/milestones_controller_spec.rb
spec/controllers/projects/milestones_controller_spec.rb
+1
-1
No files found.
app/controllers/projects/labels_controller.rb
View file @
a0930b83
...
...
@@ -112,7 +112,7 @@ class Projects::LabelsController < Projects::ApplicationController
begin
return
render_404
unless
promote_service
.
execute
(
@label
)
flash
[
:notice
]
=
"
#{
@label
.
title
}
promoted to <a href=
\"
#{
group_labels_path
(
@project
.
group
)
}
\"
>group label</a>."
.
html_safe
flash
[
:notice
]
=
flash_notice_for
(
@label
,
@project
.
group
)
respond_to
do
|
format
|
format
.
html
do
redirect_to
(
project_labels_path
(
@project
),
status: :see_other
)
...
...
@@ -135,6 +135,15 @@ class Projects::LabelsController < Projects::ApplicationController
end
end
def
flash_notice_for
(
label
,
group
)
notice
=
''
.
html_safe
notice
<<
label
.
title
notice
<<
' promoted to '
notice
<<
view_context
.
link_to
(
'<u>group label</u>'
.
html_safe
,
group_labels_path
(
group
))
notice
<<
'.'
notice
end
protected
def
label_params
...
...
app/controllers/projects/milestones_controller.rb
View file @
a0930b83
class
Projects::MilestonesController
<
Projects
::
ApplicationController
include
ActionView
::
Helpers
::
SanitizeHelper
include
Gitlab
::
Utils
::
StrongMemoize
include
MilestoneActions
...
...
@@ -77,8 +76,8 @@ class Projects::MilestonesController < Projects::ApplicationController
def
promote
promoted_milestone
=
Milestones
::
PromoteService
.
new
(
project
,
current_user
).
execute
(
milestone
)
milestone_title
=
sanitize
(
milestone
.
title
)
flash
[
:notice
]
=
"
#{
milestone_title
}
promoted to <a href=
\"
#{
group_milestone_path
(
project
.
group
,
promoted_milestone
.
iid
)
}
\"
><u>group milestone</u></a>."
.
html_safe
flash
[
:notice
]
=
flash_notice_for
(
promoted_milestone
,
project
.
group
)
respond_to
do
|
format
|
format
.
html
do
redirect_to
project_milestones_path
(
project
)
...
...
@@ -91,6 +90,15 @@ class Projects::MilestonesController < Projects::ApplicationController
redirect_to
milestone
,
alert:
error
.
message
end
def
flash_notice_for
(
milestone
,
group
)
notice
=
''
.
html_safe
notice
<<
milestone
.
title
notice
<<
' promoted to '
notice
<<
view_context
.
link_to
(
'<u>group milestone</u>'
.
html_safe
,
group_milestone_path
(
group
,
milestone
.
iid
))
notice
<<
'.'
notice
end
def
destroy
return
access_denied!
unless
can?
(
current_user
,
:admin_milestone
,
@project
)
...
...
spec/controllers/projects/labels_controller_spec.rb
View file @
a0930b83
...
...
@@ -143,6 +143,14 @@ describe Projects::LabelsController do
expect
(
GroupLabel
.
find_by
(
title:
promoted_label_name
)).
not_to
be_nil
end
it
'renders label name without parsing it as HTML'
do
label_1
.
update!
(
name:
'CCC<img src=x onerror=alert(document.domain)>'
)
post
:promote
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
id:
label_1
.
to_param
expect
(
flash
[
:notice
]).
to
eq
(
"CCC<img src=x onerror=alert(document.domain)> promoted to <a href=
\"
#{
group_labels_path
(
project
.
group
)
}
\"
><u>group label</u></a>."
)
end
context
'service raising InvalidRecord'
do
before
do
expect_any_instance_of
(
Labels
::
PromoteService
).
to
receive
(
:execute
)
do
|
label
|
...
...
spec/controllers/projects/milestones_controller_spec.rb
View file @
a0930b83
...
...
@@ -133,7 +133,7 @@ describe Projects::MilestonesController do
post
:promote
,
namespace_id:
project
.
namespace
.
id
,
project_id:
project
.
id
,
id:
milestone
.
iid
expect
(
flash
[
:notice
]).
to
eq
(
"CCC
<img src=
\"
x
\"
>
promoted to <a href=
\"
#{
group_milestone_path
(
project
.
group
,
milestone
.
iid
)
}
\"
><u>group milestone</u></a>."
)
expect
(
flash
[
:notice
]).
to
eq
(
"CCC promoted to <a href=
\"
#{
group_milestone_path
(
project
.
group
,
milestone
.
iid
)
}
\"
><u>group milestone</u></a>."
)
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