diff options
author | Christoph (Sheogorath) Kern | 2018-11-06 19:11:56 +0100 |
---|---|---|
committer | GitHub | 2018-11-06 19:11:56 +0100 |
commit | e17522add9bb5fdbe8019468b377c3e8bae9c4cf (patch) | |
tree | 68d6800689319df3160576660b9581a0b8f3ebf4 /public | |
parent | 64e9dfd7140a90ca388eed3e0c26df800850e799 (diff) | |
parent | d188b3526ab45f989e09f2a1c1f6e7a7eacf1605 (diff) |
Merge pull request #1034 from SISheogorath/fix/emojiPlugin
Again: Replace emoji-plugin regex
Diffstat (limited to 'public')
-rw-r--r-- | public/js/extra.js | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/public/js/extra.js b/public/js/extra.js index 4db36ff6..ed1470be 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -1147,15 +1147,14 @@ const pdfPlugin = new Plugin( const emojijsPlugin = new Plugin( // regexp to match emoji shortcodes :something: - /:([^\s:]+):/, + // We generate an universal regex that guaranteed only contains the + // emojies we have available. This should prevent all false-positives + new RegExp(':(' + window.emojify.emojiNames.map((item) => { return RegExp.escape(item) }).join('|') + '):', 'i'), (match, utils) => { - const emoji = match[1] ? match[1].toLowerCase() : undefined - if (window.emojify.emojiNames.includes(emoji)) { - const div = $(`<img class="emoji" src="${serverurl}/build/emojify.js/dist/images/basic/${emoji}.png"></img>`) - return div[0].outerHTML - } - return match[0] + const emoji = match[1].toLowerCase() + const div = $(`<img class="emoji" src="${serverurl}/build/emojify.js/dist/images/basic/${emoji}.png"></img>`) + return div[0].outerHTML } ) |