Browse Source

Apply custom digital entity logic before entities decode

pull/901/head
MattIPv4 2 years ago
parent
commit
9c1407433c
  1. 12
      lib/common/utils.js

12
lib/common/utils.js

@ -82,11 +82,6 @@ var decodeHTML = require('entities').decodeHTML;
function replaceEntityPattern(match, name) {
var decoded, code;
decoded = decodeHTML(match);
if (decoded !== match) {
return decoded;
}
if (name.charCodeAt(0) === 0x23/* # */ && DIGITAL_ENTITY_TEST_RE.test(name)) {
code = name[1].toLowerCase() === 'x' ?
parseInt(name.slice(2), 16) : parseInt(name.slice(1), 10);
@ -94,6 +89,13 @@ function replaceEntityPattern(match, name) {
if (isValidEntityCode(code)) {
return fromCodePoint(code);
}
return match;
}
decoded = decodeHTML(match);
if (decoded !== match) {
return decoded;
}
return match;

Loading…
Cancel
Save