Skip to content

Commit

Permalink
fix: trim URIs
Browse files Browse the repository at this point in the history
URIs used for namespaces must be trimmed. The algorithm to check for
duplicate attributes needs to not be thrown off by spaces before or
after the URIs. We also record them trimmed in the data we pass to
events handlers.
  • Loading branch information
lddubeau committed Jul 4, 2018
1 parent 52151e0 commit 78cc6f3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/saxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -885,9 +885,11 @@ class SAXParser {

let { ns } = tag;
let disconnectedNS = false;
for (const [name, uri] of this.attribList) {
// eslint-disable-next-line prefer-const
for (let [name, uri] of this.attribList) {
const { prefix, local } = this.qname(name, true);
if (prefix === "xmlns") {
uri = uri.trim();
// namespace binding attribute. push the binding into scope
if (local === "xml" && uri !== XML_NAMESPACE) {
this.fail(`xml: prefix must be bound to ${XML_NAMESPACE}\n` +
Expand Down

0 comments on commit 78cc6f3

Please sign in to comment.