Skip to content

Exclude character controls from XML output. Fixes #234 #262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 '&lt;';
case '>': return '&gt;';
Expand Down
3 changes: 3 additions & 0 deletions spec/unit/utils/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ describe("utils", function() {
expect(utils.xmlEncode('"')).to.equal('&quot;');
expect(utils.xmlEncode("'")).to.equal('&apos;');

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('<a href="www.whatever.com">Talk to the H&</a>')).to.equal('&lt;a href=&quot;www.whatever.com&quot;&gt;Talk to the H&amp;&lt;/a&gt;');
});
});
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