From 861d6774d6814b14eb3464bcb42be6c8b25158f5 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Tue, 21 May 2019 17:29:50 -0300 Subject: [PATCH] Escape shortname before matching against ns.shortnames --- lib/js/emojione.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/js/emojione.js b/lib/js/emojione.js index 7fcb24d1b..5b9a444d3 100644 --- a/lib/js/emojione.js +++ b/lib/js/emojione.js @@ -251,7 +251,7 @@ var replaceWith,shortname,unicode,fname,alt,category,title,size,ePath; var mappedUnicode = ns.mapUnicodeToShort(); str = str.replace(ns.regShortNames, function(shortname) { - if( (typeof shortname === 'undefined') || (shortname === '') || (ns.shortnames.indexOf(shortname) === -1) ) { + if( (typeof shortname === 'undefined') || (shortname === '') || (ns.shortnames.indexOf(shortname.replace(/[+]/g, '\\$&')) === -1) ) { // if the shortname doesnt exist just return the entire match return shortname; } @@ -496,4 +496,4 @@ }; }(this.emojione = this.emojione || {})); -if(typeof module === "object") module.exports = this.emojione; \ No newline at end of file +if(typeof module === "object") module.exports = this.emojione;