From 794a50d3f373d0003a88fa68ff047539f3deaed3 Mon Sep 17 00:00:00 2001 From: Mike Fix Date: Mon, 21 Jan 2019 15:56:11 -0800 Subject: [PATCH] fix # issues for SVGs Closes #640 --- components/Editor.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/Editor.js b/components/Editor.js index fb3540f..4279f93 100644 --- a/components/Editor.js +++ b/components/Editor.js @@ -180,7 +180,13 @@ class Editor extends React.Component { return ( domtoimage .toSvg(node, config) - .then(dataUrl => dataUrl.replace(/ /g, ' ')) + .then(dataUrl => + dataUrl + .replace(/ /g, ' ') + // https://github.com/tsayen/dom-to-image/blob/fae625bce0970b3a039671ea7f338d05ecb3d0e8/src/dom-to-image.js#L551 + .replace(/%23/g, '#') + .replace(/%0A/, '\n') + ) // https://stackoverflow.com/questions/7604436/xmlparseentityref-no-name-warnings-while-loading-xml-into-a-php-file .then(dataUrl => dataUrl.replace(/&(?!#?[a-z0-9]+;)/g, '&')) .then(uri => uri.slice(uri.indexOf(',') + 1))