repo: janusweb action: commit revision: path_from: revision_from: 53a1d0837d1e65f731b2485e7b4562253cdd3a23: path_to: revision_to:
commit 53a1d0837d1e65f731b2485e7b4562253cdd3a23 Author: James BaicoianuDate: Wed Dec 11 17:04:23 2019 -0800 Fixed XML parse error handling for Firefox diff --git a/scripts/external/JanusFireboxParser.js b/scripts/external/JanusFireboxParser.js
--- a/scripts/external/JanusFireboxParser.js
+++ b/scripts/external/JanusFireboxParser.js
@@ -234,7 +234,7 @@ JanusFireboxParser.prototype.parseXML = function(imgxml, leaf, forceLower) {
if (window.DOMParser) {
var parser = new DOMParser();
xmldoc = parser.parseFromString(imgxml,"application/xml");
- node = xmldoc.firstChild;
+ node = xmldoc.children[0];
} else {
node = new ActiveXObject("Microsoft.XMLDOM");
node.async = "false";
@@ -242,7 +242,8 @@ JanusFireboxParser.prototype.parseXML = function(imgxml, leaf, forceLower) {
}
// Chrome doesn't throw an exception for malformed XML, so we look for a xml tag
- var parsererrors = node.getElementsByTagName("parsererror");
+ // Firefox now appears to follow the same behavior, but puts the as the top-level element instead of as a child of the last DOM element which parsed successfully
+ var parsererrors = (node.tagName == 'parsererror' ? [node] : node.getElementsByTagName("parsererror"));
if (parsererrors.length > 0) {
// Extract the message from the first div child of the element
var errorel = parsererrors[0].getElementsByTagName('div')[0] || parsererrors[0];
-----END OF PAGE-----