diff --git a/src/js/sanitize.js b/src/js/sanitize.js index 98e5687..a8e3156 100644 --- a/src/js/sanitize.js +++ b/src/js/sanitize.js @@ -147,6 +147,7 @@ svgedit.sanitize.sanitizeSvg = function(node) { if(!node.nodeValue.length) node.parentNode.removeChild(node); } if (node.nodeType != 1) return; + var doc = node.ownerDocument; var parent = node.parentNode; // can parent ever be null here? I think the root node's parent is the document... @@ -195,7 +196,7 @@ svgedit.sanitize.sanitizeSvg = function(node) { // for the style attribute, rewrite it in terms of XML presentational attributes if (attrName == "style") { - var props = attr.nodeValue.split(";"), + var props = attr.nodeValue.replace(' ', '').split(";"), p = props.length; while(p--) { var nv = props[p].split(":"); @@ -220,7 +221,7 @@ svgedit.sanitize.sanitizeSvg = function(node) { "radialGradient", "textPath", "use"].indexOf(node.nodeName) >= 0) { // TODO: we simply check if the first character is a #, is this bullet-proof? - if (href[0] != "#") { + if (href[0] !== "#") { // remove the attribute (but keep the element) svgedit.utilities.setHref(node, ""); node.removeAttributeNS(xlinkns, "href"); diff --git a/src/js/svgcanvas.js b/src/js/svgcanvas.js index b39901f..4ce73be 100644 --- a/src/js/svgcanvas.js +++ b/src/js/svgcanvas.js @@ -5786,6 +5786,8 @@ this.setSvgString = function(xmlString) { try { // convert string into XML document var newDoc = svgedit.utilities.text2xml(xmlString); + //var parser = new DOMParser(); + //var newDoc = parser.parseFromString(stringContainingXMLSource, "image/svg+xml"); this.prepareSvg(newDoc); diff --git a/src/js/svgutils.js b/src/js/svgutils.js index eccec5b..ec75f57 100644 --- a/src/js/svgutils.js +++ b/src/js/svgutils.js @@ -218,6 +218,10 @@ svgedit.utilities.text2xml = function(sXML) { sXML = sXML.replace(/<(\/?)svg:/g, '<$1').replace('xmlns:svg', 'xmlns'); } + if(sXML.indexOf('xlink:href') >= 0) { + sXML = sXML.replace('xlink:href', 'href'); + } + var out; try{ var dXML = (window.DOMParser)?new DOMParser():new ActiveXObject("Microsoft.XMLDOM");