Commit 1fb53785 authored by JC Brand's avatar JC Brand

Throw error on parser error in `toStanza`

parent f30d415f
......@@ -33,8 +33,16 @@ u.isTagEqual = function (stanza, name) {
}
}
const parser = new DOMParser();
const parserErrorNS = parser.parseFromString('invalid', 'text/xml')
.getElementsByTagName("parsererror")[0].namespaceURI;
u.toStanza = function (string) {
return Strophe.xmlHtmlNode(string).firstElementChild;
const node = parser.parseFromString(string, "text/xml");
if (node.getElementsByTagNameNS(parserErrorNS, 'parsererror').length) {
throw new Error(`Parser Error: ${string}`);
}
return node.firstElementChild;
}
u.getLongestSubstring = function (string, candidates) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment