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
7f25701b
Commit
7f25701b
authored
Jan 30, 2020
by
Luke Duncalfe
Committed by
Natalia Tepluhina
Jan 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly escape wiki commit message characters
https://gitlab.com/gitlab-org/gitlab/issues/35478
parent
a15388de
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
6 deletions
+23
-6
app/assets/javascripts/pages/projects/wikis/wikis.js
app/assets/javascripts/pages/projects/wikis/wikis.js
+1
-1
changelogs/unreleased/21371-auto-generated-wiki-commit-message-having-html-encoded-entities.yml
...ated-wiki-commit-message-having-html-encoded-entities.yml
+5
-0
spec/features/projects/wiki/user_updates_wiki_page_spec.rb
spec/features/projects/wiki/user_updates_wiki_page_spec.rb
+5
-5
spec/features/projects/wiki/user_views_wiki_page_spec.rb
spec/features/projects/wiki/user_views_wiki_page_spec.rb
+12
-0
No files found.
app/assets/javascripts/pages/projects/wikis/wikis.js
View file @
7f25701b
...
...
@@ -40,7 +40,7 @@ export default class Wikis {
// Replace hyphens with spaces
if
(
title
)
title
=
title
.
replace
(
/-+/g
,
'
'
);
const
newCommitMessage
=
sprintf
(
this
.
commitMessageI18n
,
{
pageTitle
:
title
});
const
newCommitMessage
=
sprintf
(
this
.
commitMessageI18n
,
{
pageTitle
:
title
}
,
false
);
this
.
commitMessageInput
.
value
=
newCommitMessage
;
}
...
...
changelogs/unreleased/21371-auto-generated-wiki-commit-message-having-html-encoded-entities.yml
0 → 100644
View file @
7f25701b
---
title
:
Auto generated wiki commit message containing HTML encoded entities
merge_request
:
21371
author
:
2knal
type
:
other
spec/features/projects/wiki/user_updates_wiki_page_spec.rb
View file @
7f25701b
...
...
@@ -83,15 +83,15 @@ describe 'User updates wiki page' do
end
it
'updates the commit message as the title is changed'
,
:js
do
fill_in
(
:wiki_title
,
with:
'
Wiki title
'
)
fill_in
(
:wiki_title
,
with:
'
& < > \ \ { } &
'
)
expect
(
page
).
to
have_field
(
'wiki[message]'
,
with:
'Update
Wiki title
'
)
expect
(
page
).
to
have_field
(
'wiki[message]'
,
with:
'Update
& < > \ \ { } &
'
)
end
it
'
does not allow XSS
'
,
:js
do
fill_in
(
:wiki_title
,
with:
'
<script>
'
)
it
'
correctly escapes the commit message entities
'
,
:js
do
fill_in
(
:wiki_title
,
with:
'
Wiki title
'
)
expect
(
page
).
to
have_field
(
'wiki[message]'
,
with:
'Update
<script>
'
)
expect
(
page
).
to
have_field
(
'wiki[message]'
,
with:
'Update
Wiki title
'
)
end
it
'shows a validation error message'
do
...
...
spec/features/projects/wiki/user_views_wiki_page_spec.rb
View file @
7f25701b
...
...
@@ -129,6 +129,18 @@ describe 'User views a wiki page' do
end
end
context
'when a page has XSS in its message'
do
before
do
wiki_page
.
update
(
message:
'<script>alert(true)<script>'
,
content:
'XSS update'
)
end
it
'safely displays the message'
do
visit
(
project_wiki_history_path
(
project
,
wiki_page
))
expect
(
page
).
to
have_content
(
'<script>alert(true)<script>'
)
end
end
context
'when page has invalid content encoding'
do
let
(
:content
)
{
(
+
'whatever'
).
force_encoding
(
'ISO-8859-1'
)
}
...
...
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