diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-10-14 19:26:10 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-10-14 19:26:10 +0100 |
| commit | 9de6bed1cd4f24f591c4aa2a3012501bd792c157 (patch) | |
| tree | fbbab3fd96a8c48c124aef2e4ec34317c7a40440 /lib | |
| parent | e55b8f2614fccb2ac54b3ddebe1ed3eeb12e32c9 (diff) | |
Don't escape double quotes outside of attributes
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/writers/html-writer.js | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/writers/html-writer.js b/lib/writers/html-writer.js index f1761c9..456e894 100644 --- a/lib/writers/html-writer.js +++ b/lib/writers/html-writer.js @@ -114,12 +114,12 @@ function simpleWriter() { function generateAttributeString(attributes) { return _.map(attributes, function(value, key) { - return util.format(' %s="%s"', key, escapeHtml(value)); + return util.format(' %s="%s"', key, escapeHtmlAttribute(value)); }).join(""); } function text(value) { - fragments.push(escapeHtml(value)); + fragments.push(escapeHtmlText(value)); } function append(html) { @@ -140,8 +140,14 @@ function simpleWriter() { }; } +function escapeHtmlText(value) { + return value + .replace(/&/g, '&') + .replace(/</g, '<') + .replace(/>/g, '>'); +} -function escapeHtml(value) { +function escapeHtmlAttribute(value) { return value .replace(/&/g, '&') .replace(/"/g, '"') |
