Skip to content

Commit

Permalink
fix: "X" is not a valid hex prefix for char references
Browse files Browse the repository at this point in the history
  • Loading branch information
lddubeau committed Jul 6, 2018
1 parent 604241f commit 465038b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/saxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion test/issue-35.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// https://github.com/isaacs/sax-js/issues/35
require(".").test({
name: "issue 35 (leading 0 in entity numeric code)",
xml: "<xml>&#Xd;&#X0d;\n</xml>",
xml: "<xml>&#xd;&#x0d;\n</xml>",
expect: [
["opentagstart", { name: "xml", attributes: {} }],
["opentag", { name: "xml", attributes: {}, isSelfClosing: false }],
Expand Down

0 comments on commit 465038b

Please sign in to comment.