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
43e4988e
Commit
43e4988e
authored
Nov 26, 2019
by
Brian T
Committed by
Phil Hughes
Nov 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix award emoji tooltip being escaped twice if multiple people voted
parent
ad290106
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
5 deletions
+74
-5
app/assets/javascripts/notes/components/note_awards_list.vue
app/assets/javascripts/notes/components/note_awards_list.vue
+9
-5
changelogs/unreleased/30036-award-emoji-tooltip-is-escaped-twice.yml
...unreleased/30036-award-emoji-tooltip-is-escaped-twice.yml
+5
-0
spec/javascripts/notes/components/note_awards_list_spec.js
spec/javascripts/notes/components/note_awards_list_spec.js
+60
-0
No files found.
app/assets/javascripts/notes/components/note_awards_list.vue
View file @
43e4988e
...
@@ -116,16 +116,20 @@ export default {
...
@@ -116,16 +116,20 @@ export default {
// We have 10+ awarded user, join them with comma and add `and x more`.
// We have 10+ awarded user, join them with comma and add `and x more`.
if
(
remainingAwardList
.
length
)
{
if
(
remainingAwardList
.
length
)
{
title
=
sprintf
(
__
(
`%{listToShow}, and %{awardsListLength} more.`
),
{
title
=
sprintf
(
listToShow
:
namesToShow
.
join
(
'
,
'
),
__
(
`%{listToShow}, and %{awardsListLength} more.`
),
awardsListLength
:
remainingAwardList
.
length
,
{
});
listToShow
:
namesToShow
.
join
(
'
,
'
),
awardsListLength
:
remainingAwardList
.
length
,
},
false
,
);
}
else
if
(
namesToShow
.
length
>
1
)
{
}
else
if
(
namesToShow
.
length
>
1
)
{
// Join all names with comma but not the last one, it will be added with and text.
// Join all names with comma but not the last one, it will be added with and text.
title
=
namesToShow
.
slice
(
0
,
namesToShow
.
length
-
1
).
join
(
'
,
'
);
title
=
namesToShow
.
slice
(
0
,
namesToShow
.
length
-
1
).
join
(
'
,
'
);
// If we have more than 2 users we need an extra comma before and text.
// If we have more than 2 users we need an extra comma before and text.
title
+=
namesToShow
.
length
>
2
?
'
,
'
:
''
;
title
+=
namesToShow
.
length
>
2
?
'
,
'
:
''
;
title
+=
sprintf
(
__
(
` and %{sliced}`
),
{
sliced
:
namesToShow
.
slice
(
-
1
)
});
// Append and text
title
+=
sprintf
(
__
(
` and %{sliced}`
),
{
sliced
:
namesToShow
.
slice
(
-
1
)
}
,
false
);
// Append and text
}
else
{
}
else
{
// We have only 2 users so join them with and.
// We have only 2 users so join them with and.
title
=
namesToShow
.
join
(
__
(
'
and
'
));
title
=
namesToShow
.
join
(
__
(
'
and
'
));
...
...
changelogs/unreleased/30036-award-emoji-tooltip-is-escaped-twice.yml
0 → 100644
View file @
43e4988e
---
title
:
Fix award emoji tooltip being escaped twice if multiple people voted
merge_request
:
19273
author
:
Brian T
type
:
fixed
spec/javascripts/notes/components/note_awards_list_spec.js
View file @
43e4988e
...
@@ -61,6 +61,66 @@ describe('note_awards_list component', () => {
...
@@ -61,6 +61,66 @@ describe('note_awards_list component', () => {
expect
(
vm
.
$el
.
querySelector
(
'
.js-add-award
'
)).
toBeDefined
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-add-award
'
)).
toBeDefined
();
});
});
describe
(
'
when the user name contains special HTML characters
'
,
()
=>
{
const
createAwardEmoji
=
(
_
,
index
)
=>
({
name
:
'
art
'
,
user
:
{
id
:
index
,
name
:
`&<>"\`'-
${
index
}
`
,
username
:
`user-
${
index
}
`
},
});
const
mountComponent
=
()
=>
{
const
Component
=
Vue
.
extend
(
awardsNote
);
vm
=
new
Component
({
store
,
propsData
:
{
awards
:
awardsMock
,
noteAuthorId
:
0
,
noteId
:
'
545
'
,
canAwardEmoji
:
true
,
toggleAwardPath
:
'
/gitlab-org/gitlab-foss/notes/545/toggle_award_emoji
'
,
},
}).
$mount
();
};
const
findTooltip
=
()
=>
vm
.
$el
.
querySelector
(
'
[data-original-title]
'
).
getAttribute
(
'
data-original-title
'
);
it
(
'
should only escape & and " characters
'
,
()
=>
{
awardsMock
=
[...
new
Array
(
1
)].
map
(
createAwardEmoji
);
mountComponent
();
const
escapedName
=
awardsMock
[
0
].
user
.
name
.
replace
(
/&/g
,
'
&
'
).
replace
(
/"/g
,
'
"
'
);
expect
(
vm
.
$el
.
querySelector
(
'
[data-original-title]
'
).
outerHTML
).
toContain
(
escapedName
);
});
it
(
'
should not escape special HTML characters twice when only 1 person awarded
'
,
()
=>
{
awardsMock
=
[...
new
Array
(
1
)].
map
(
createAwardEmoji
);
mountComponent
();
awardsMock
.
forEach
(
award
=>
{
expect
(
findTooltip
()).
toContain
(
award
.
user
.
name
);
});
});
it
(
'
should not escape special HTML characters twice when 2 people awarded
'
,
()
=>
{
awardsMock
=
[...
new
Array
(
2
)].
map
(
createAwardEmoji
);
mountComponent
();
awardsMock
.
forEach
(
award
=>
{
expect
(
findTooltip
()).
toContain
(
award
.
user
.
name
);
});
});
it
(
'
should not escape special HTML characters twice when more than 10 people awarded
'
,
()
=>
{
awardsMock
=
[...
new
Array
(
11
)].
map
(
createAwardEmoji
);
mountComponent
();
// Testing only the first 10 awards since 11 onward will not be displayed.
awardsMock
.
slice
(
0
,
10
).
forEach
(
award
=>
{
expect
(
findTooltip
()).
toContain
(
award
.
user
.
name
);
});
});
});
describe
(
'
when the user cannot award emoji
'
,
()
=>
{
describe
(
'
when the user cannot award emoji
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
const
Component
=
Vue
.
extend
(
awardsNote
);
const
Component
=
Vue
.
extend
(
awardsNote
);
...
...
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