Skip to content

Commit e17522a

Browse files
authored
Merge pull request #1034 from SISheogorath/fix/emojiPlugin
Again: Replace emoji-plugin regex
2 parents 64e9dfd + d188b35 commit e17522a

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

public/js/extra.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,15 +1147,14 @@ const pdfPlugin = new Plugin(
11471147

11481148
const emojijsPlugin = new Plugin(
11491149
// regexp to match emoji shortcodes :something:
1150-
/:([^\s:]+):/,
1150+
// We generate an universal regex that guaranteed only contains the
1151+
// emojies we have available. This should prevent all false-positives
1152+
new RegExp(':(' + window.emojify.emojiNames.map((item) => { return RegExp.escape(item) }).join('|') + '):', 'i'),
11511153

11521154
(match, utils) => {
1153-
const emoji = match[1] ? match[1].toLowerCase() : undefined
1154-
if (window.emojify.emojiNames.includes(emoji)) {
1155-
const div = $(`<img class="emoji" src="${serverurl}/build/emojify.js/dist/images/basic/${emoji}.png"></img>`)
1156-
return div[0].outerHTML
1157-
}
1158-
return match[0]
1155+
const emoji = match[1].toLowerCase()
1156+
const div = $(`<img class="emoji" src="${serverurl}/build/emojify.js/dist/images/basic/${emoji}.png"></img>`)
1157+
return div[0].outerHTML
11591158
}
11601159
)
11611160

0 commit comments

Comments
 (0)