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
ad8f7a40
Commit
ad8f7a40
authored
Jan 06, 2022
by
Phil Hughes
Committed by
GitLab Release Tools Bot
Jan 06, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes gl-emoji not escaping names
parent
aa29ece0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
3 deletions
+30
-3
app/assets/javascripts/behaviors/gl_emoji.js
app/assets/javascripts/behaviors/gl_emoji.js
+4
-2
app/assets/javascripts/emoji/index.js
app/assets/javascripts/emoji/index.js
+14
-1
spec/frontend/behaviors/gl_emoji_spec.js
spec/frontend/behaviors/gl_emoji_spec.js
+12
-0
No files found.
app/assets/javascripts/behaviors/gl_emoji.js
View file @
ad8f7a40
...
...
@@ -64,10 +64,12 @@ class GlEmoji extends HTMLElement {
this
.
classList
.
add
(
'
emoji-icon
'
);
this
.
classList
.
add
(
fallbackSpriteClass
);
}
else
if
(
hasImageFallback
)
{
this
.
innerHTML
=
emojiImageTag
(
name
,
fallbackSrc
);
this
.
innerHTML
=
''
;
this
.
appendChild
(
emojiImageTag
(
name
,
fallbackSrc
));
}
else
{
const
src
=
emojiFallbackImageSrc
(
name
);
this
.
innerHTML
=
emojiImageTag
(
name
,
src
);
this
.
innerHTML
=
''
;
this
.
appendChild
(
emojiImageTag
(
name
,
src
));
}
}
});
...
...
app/assets/javascripts/emoji/index.js
View file @
ad8f7a40
import
{
escape
,
minBy
}
from
'
lodash
'
;
import
emojiRegexFactory
from
'
emoji-regex
'
;
import
emojiAliases
from
'
emojis/aliases.json
'
;
import
{
setAttributes
}
from
'
~/lib/utils/dom_utils
'
;
import
AccessorUtilities
from
'
../lib/utils/accessor
'
;
import
axios
from
'
../lib/utils/axios_utils
'
;
import
{
CACHE_KEY
,
CACHE_VERSION_KEY
,
CATEGORY_ICON_MAP
,
FREQUENTLY_USED_KEY
}
from
'
./constants
'
;
...
...
@@ -220,7 +221,19 @@ export function emojiFallbackImageSrc(inputName) {
}
export
function
emojiImageTag
(
name
,
src
)
{
return
`<img class="emoji" title=":
${
name
}
:" alt=":
${
name
}
:" src="
${
src
}
" width="20" height="20" align="absmiddle" />`
;
const
img
=
document
.
createElement
(
'
img
'
);
img
.
className
=
'
emoji
'
;
setAttributes
(
img
,
{
title
:
`:
${
name
}
:`
,
alt
:
`:
${
name
}
:`
,
src
,
width
:
'
20
'
,
height
:
'
20
'
,
align
:
'
absmiddle
'
,
});
return
img
;
}
export
function
glEmojiTag
(
inputName
,
options
)
{
...
...
spec/frontend/behaviors/gl_emoji_spec.js
View file @
ad8f7a40
...
...
@@ -97,6 +97,18 @@ describe('gl_emoji', () => {
});
});
it
(
'
escapes gl-emoji name
'
,
async
()
=>
{
const
glEmojiElement
=
markupToDomElement
(
"
<gl-emoji data-name='"x="y" onload="alert(document.location.href)"' data-unicode-version='x'>abc</gl-emoji>
"
,
);
await
waitForPromises
();
expect
(
glEmojiElement
.
outerHTML
).
toBe
(
'
<gl-emoji data-name=""x="y" onload="alert(document.location.href)"" data-unicode-version="x"><img class="emoji" title=":"x="y" onload="alert(document.location.href)":" alt=":"x="y" onload="alert(document.location.href)":" src="/-/emojis/2/grey_question.png" width="20" height="20" align="absmiddle"></gl-emoji>
'
,
);
});
it
(
'
Adds sprite CSS if emojis are not supported
'
,
async
()
=>
{
const
testPath
=
'
/test-path.css
'
;
jest
.
spyOn
(
EmojiUnicodeSupport
,
'
default
'
).
mockReturnValue
(
false
);
...
...
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