diff --git a/app/js/lib/ng_utils.js b/app/js/lib/ng_utils.js index 96c737dc..49702af0 100644 --- a/app/js/lib/ng_utils.js +++ b/app/js/lib/ng_utils.js @@ -1425,6 +1425,7 @@ angular.module('izhukov.utils', []) if (nested === undefined) { return encodeEntities(text); } + options.hasNested = true; return wrapRichText(text, {entities: nested, nested: true}); } @@ -1642,7 +1643,7 @@ angular.module('izhukov.utils', []) text = $sanitize(html.join('')); - if (emojiFound && !options.nested) { + if (!options.nested && (emojiFound || options.hasNested)) { text = text.replace(/\ufe0f|️|�|‍/g, '', text); text = text.replace(//g, ''); diff --git a/app/js/lib/utils.js b/app/js/lib/utils.js index 347f81d8..932a5af5 100644 --- a/app/js/lib/utils.js +++ b/app/js/lib/utils.js @@ -361,6 +361,11 @@ function templateUrl (tplName) { function encodeEntities(value) { return value. replace(/&/g, '&'). + replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, function (value) { + var hi = value.charCodeAt(0); + var low = value.charCodeAt(1); + return '&#' + (((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000) + ';'; + }). replace(/([^\#-~| |!])/g, function (value) { // non-alphanumeric return '&#' + value.charCodeAt(0) + ';'; }).