diff --git a/svg.export.js b/svg.export.js index c92e027..52ba7f3 100644 --- a/svg.export.js +++ b/svg.export.js @@ -68,7 +68,7 @@ /* add tspan content */ if (this instanceof SVG.TSpan) - node += whitespaced(this.node.firstChild.nodeValue.replace(/&/g,'&'), options.whitespace, level + 1) + node += whitespaced(_encodeHtmlSpecialChars(this.node.firstChild.nodeValue), options.whitespace, level + 1) /* close node */ node += whitespaced('', options.whitespace, level) @@ -147,5 +147,13 @@ return value; } + + function _encodeHtmlSpecialChars(unsafe) { + return unsafe + .replace(/&/g, "&") + .replace(//g, ">") + .replace(/"/g, """); + } }).call(this);