From 89a3b86a09806080768f92c80a9b9cb151d89906 Mon Sep 17 00:00:00 2001 From: Louis-Dominique Dubeau Date: Tue, 8 Jan 2019 07:17:45 -0500 Subject: [PATCH] fix: generate an error on prefix with empty local name A case like used to pass. It is not wellformed due to the prefix (bar) lacking a local name. It no longer passes. Closes #5. --- lib/saxes.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/saxes.js b/lib/saxes.js index 45b68ab4..e9c99f5d 100644 --- a/lib/saxes.js +++ b/lib/saxes.js @@ -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 */