Skip to content

Commit

Permalink
fix: generate an error on prefix with empty local name
Browse files Browse the repository at this point in the history
A case like <foo bar:="1"/> used to pass. It is not wellformed due to the prefix
(bar) lacking a local name. It no longer passes.

Closes lddubeau#5.
  • Loading branch information
lddubeau committed Jan 8, 2019
1 parent d153112 commit 89a3b86
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions lib/saxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -1658,20 +1658,13 @@ class SaxesParser {
return { prefix: "", local: name };
}

// A colon at the start of the name is illegal.
if (colon === 0) {
this.fail(`malformed name: ${name}.`);
}

const local = name.substring(colon + 1);
if (local.indexOf(":") !== -1) {
const prefix = name.substring(0, colon);
if (prefix === "" || local === "" || local.indexOf(":") !== -1) {
this.fail(`malformed name: ${name}.`);
}

return {
prefix: name.substring(0, colon),
local,
};
return { prefix, local };
}

/** @private */
Expand Down

0 comments on commit 89a3b86

Please sign in to comment.