From d072aa75004439f3a3692005b2e65a1c3a12b7e4 Mon Sep 17 00:00:00 2001 From: adambar Date: Thu, 2 Feb 2017 13:27:51 +0100 Subject: [PATCH] Exclude character controls from XML output. Fixes #234 --- lib/utils/utils.js | 2 +- spec/unit/utils/utils.spec.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/utils/utils.js b/lib/utils/utils.js index 1a6b85762..5fd178292 100644 --- a/lib/utils/utils.js +++ b/lib/utils/utils.js @@ -136,7 +136,7 @@ var utils = module.exports = { return path.path + '/_rels/' + path.name + '.rels'; }, xmlEncode: function(text) { - return text.replace(/[<>&'"]/g, function (c) { + return text.replace(/[<>&'"\x7F\x00-\x1F]/g, function (c) { switch (c) { case '<': return '<'; case '>': return '>'; diff --git a/spec/unit/utils/utils.spec.js b/spec/unit/utils/utils.spec.js index 8fa9206c5..078ef0065 100644 --- a/spec/unit/utils/utils.spec.js +++ b/spec/unit/utils/utils.spec.js @@ -13,6 +13,9 @@ describe("utils", function() { expect(utils.xmlEncode('"')).to.equal('"'); expect(utils.xmlEncode("'")).to.equal('''); + expect(utils.xmlEncode("abc\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0b\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20abc\x7f")) + .to.equal('abc abc'); + expect(utils.xmlEncode('Talk to the H&')).to.equal('<a href="www.whatever.com">Talk to the H&</a>'); }); }); \ No newline at end of file pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy