Browse Source

Fixed encodeEntities

Also fixed nested emojis in links
Closes #702
master
Igor Zhukov 9 years ago
parent
commit
fd994fdd97
  1. 3
      app/js/lib/ng_utils.js
  2. 5
      app/js/lib/utils.js

3
app/js/lib/ng_utils.js

@ -1425,6 +1425,7 @@ angular.module('izhukov.utils', []) @@ -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', []) @@ -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(/<span class="emoji emoji-(\d)-(\d+)-(\d+)"(.+?)<\/span>/g,
'<span class="emoji emoji-spritesheet-$1" style="background-position: -$2px -$3px;" $4</span>');

5
app/js/lib/utils.js

@ -361,6 +361,11 @@ function templateUrl (tplName) { @@ -361,6 +361,11 @@ function templateUrl (tplName) {
function encodeEntities(value) {
return value.
replace(/&/g, '&amp;').
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) + ';';
}).

Loading…
Cancel
Save