diff --git a/webapp/channels/src/utils/emoticons.test.tsx b/webapp/channels/src/utils/emoticons.test.tsx index b85b41bf2c..53ff214d4c 100644 --- a/webapp/channels/src/utils/emoticons.test.tsx +++ b/webapp/channels/src/utils/emoticons.test.tsx @@ -31,6 +31,11 @@ describe('Emoticons', () => { expect(Emoticons.handleEmoticons(emoticon, new Map())).toEqual('$MM_EMOTICON0$'); }); }); + Array.prototype.concat(...Object.values(emoticonPatterns)).forEach((emoticon) => { + test(`escaped text sequence '${emoticon}' should not be recognized as an emoticon`, () => { + expect(Emoticons.handleEmoticons('\\' + emoticon, new Map())).toEqual(emoticon); + }); + }); // test various uses of emoticons test('should replace emoticons with tokens', () => { diff --git a/webapp/channels/src/utils/emoticons.tsx b/webapp/channels/src/utils/emoticons.tsx index 92fe50e14e..51cdd5923f 100644 --- a/webapp/channels/src/utils/emoticons.tsx +++ b/webapp/channels/src/utils/emoticons.tsx @@ -5,24 +5,24 @@ import {formatWithRenderer} from './markdown'; import PlainRenderer from './markdown/plain_renderer'; export const emoticonPatterns: { [key: string]: RegExp } = { - slightly_smiling_face: /(^|\B)(:-?\))($|\B)/g, // :) - wink: /(^|\B)(;-?\))($|\B)/g, // ;) - open_mouth: /(^|\B)(:o)($|\b)/gi, // :o - scream: /(^|\B)(:-o)($|\b)/gi, // :-o - smirk: /(^|\B)(:-?])($|\B)/g, // :] - smile: /(^|\B)(:-?d)($|\b)/gi, // :D - stuck_out_tongue_closed_eyes: /(^|\b)(x-d)($|\b)/gi, // x-d - stuck_out_tongue: /(^|\B)(:-?p)($|\b)/gi, // :p - rage: /(^|\B)(:-?[[@])($|\B)/g, // :@ - slightly_frowning_face: /(^|\B)(:-?\()($|\B)/g, // :( - cry: /(^|\B)(:[`'’]-?\(|:'\(|:'\()($|\B)/g, // :`( - confused: /(^|\B)(:-?\/)($|\B)/g, // :/ - confounded: /(^|\B)(:-?s)($|\b)/gi, // :s - neutral_face: /(^|\B)(:-?\|)($|\B)/g, // :| - flushed: /(^|\B)(:-?\$)($|\B)/g, // :$ - mask: /(^|\B)(:-x)($|\b)/gi, // :-x - heart: /(^|\B)(<3|<3)($|\b)/g, // <3 - broken_heart: /(^|\B)(<\/3|<\/3)($|\b)/g, //