From 465038bd381a84ea8cbfa5d65f4fbe77a2bd6e04 Mon Sep 17 00:00:00 2001 From: Louis-Dominique Dubeau Date: Fri, 6 Jul 2018 05:25:38 -0400 Subject: [PATCH] fix: "X" is not a valid hex prefix for char references --- lib/saxes.js | 2 +- test/issue-35.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/saxes.js b/lib/saxes.js index a1920d82..0a8ea1a5 100644 --- a/lib/saxes.js +++ b/lib/saxes.js @@ -1114,7 +1114,7 @@ ${XML_NAMESPACE}.`); let num = NaN; if (entity[0] === "#") { - if ((entity[1] === "x" || entity[1] === "X") && + if ((entity[1] === "x") && /^#[x|X][0-9a-fA-F]+$/.test(entity)) { num = parseInt(entity.slice(2), 16); } diff --git a/test/issue-35.js b/test/issue-35.js index 0de9e3f0..d27916ba 100644 --- a/test/issue-35.js +++ b/test/issue-35.js @@ -3,7 +3,7 @@ // https://github.com/isaacs/sax-js/issues/35 require(".").test({ name: "issue 35 (leading 0 in entity numeric code)", - xml: " \n", + xml: " \n", expect: [ ["opentagstart", { name: "xml", attributes: {} }], ["opentag", { name: "xml", attributes: {}, isSelfClosing: false }],