diff --git a/src/containers/paper-canvas.jsx b/src/containers/paper-canvas.jsx index d5d446b5..a7167ec3 100644 --- a/src/containers/paper-canvas.jsx +++ b/src/containers/paper-canvas.jsx @@ -82,6 +82,19 @@ class PaperCanvas extends React.Component { } importSvg (svg, rotationCenterX, rotationCenterY) { const paperCanvas = this; + // Pre-process SVG to prevent parsing errors (discussion from #213) + // 1. Remove newlines and tab characters, chrome will not load urls with them. + // https://www.chromestatus.com/feature/5735596811091968 + svg = svg.split(/[\n|\r|\t]/).join(''); + // 2. Remove svg: namespace on elements. + svg = svg.split(/<\s*svg:/).join('<'); + svg = svg.split(/<\/\s*svg:/).join(']*>/); + if (svgAttrs && svgAttrs[0].indexOf('xmlns=') === -1) { + svg = svg.replace( + '