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
fc9f9004
Commit
fc9f9004
authored
Jul 12, 2018
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Escapes milestone title shown in flash message when promoting a milestone
parent
cfe21219
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
2 deletions
+11
-2
app/controllers/projects/milestones_controller.rb
app/controllers/projects/milestones_controller.rb
+3
-2
spec/controllers/projects/milestones_controller_spec.rb
spec/controllers/projects/milestones_controller_spec.rb
+8
-0
No files found.
app/controllers/projects/milestones_controller.rb
View file @
fc9f9004
class
Projects::MilestonesController
<
Projects
::
ApplicationController
include
ActionView
::
Helpers
::
SanitizeHelper
include
Gitlab
::
Utils
::
StrongMemoize
include
MilestoneActions
...
...
@@ -76,8 +77,8 @@ class Projects::MilestonesController < Projects::ApplicationController
def
promote
promoted_milestone
=
Milestones
::
PromoteService
.
new
(
project
,
current_user
).
execute
(
milestone
)
flash
[
:notice
]
=
"
#{
milestone
.
title
}
promoted to <a href=
\"
#{
group_milestone_path
(
project
.
group
,
promoted_milestone
.
iid
)
}
\"
><u>group milestone</u></a>."
.
html_safe
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
respond_to
do
|
format
|
format
.
html
do
redirect_to
project_milestones_path
(
project
)
...
...
spec/controllers/projects/milestones_controller_spec.rb
View file @
fc9f9004
...
...
@@ -127,6 +127,14 @@ describe Projects::MilestonesController do
expect
(
flash
[
:notice
]).
to
eq
(
"
#{
milestone
.
title
}
promoted to <a href=
\"
#{
group_milestone_path
(
project
.
group
,
milestone
.
iid
)
}
\"
><u>group milestone</u></a>."
)
expect
(
response
).
to
redirect_to
(
project_milestones_path
(
project
))
end
it
'renders milestone name without parsing it as HTML'
do
milestone
.
update!
(
name:
'CCC<img src=x onerror=alert(document.domain)>'
)
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>."
)
end
end
context
'promotion fails'
do
...
...
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