From 1628e155445c6b2ba10bf5338c401bfc4bd2a69b Mon Sep 17 00:00:00 2001 From: Mike Fix Date: Sun, 4 Oct 2020 15:40:16 -0700 Subject: [PATCH] Revert "clean up escapePercentSign (#1101)" Closes #1115 This reverts commit a1375754f9cd8f52dd3e67f71fc9d85b2b749dfd. --- lib/dom-to-image.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/dom-to-image.js b/lib/dom-to-image.js index 8f1f974..8bd19f5 100644 --- a/lib/dom-to-image.js +++ b/lib/dom-to-image.js @@ -327,8 +327,9 @@ node.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml') return new XMLSerializer().serializeToString(node) }) - .then(util.escapeXhtml) - .then(str => (escapePercentSign ? str.replace(/%/g, '%25') : str)) + .then(function (str) { + return util.escapeXhtml(str, escapePercentSign) + }) .then(function (xhtml) { return '' + xhtml + '' }) @@ -551,7 +552,10 @@ return array } - function escapeXhtml(string) { + function escapeXhtml(string, escapePercentSign) { + if (escapePercentSign) { + string = string.replace(/%/g, '%25') + } return string.replace(/#/g, '%23').replace(/\n/g, '%0A') }