Skip to content

Commit 68838a1

Browse files
authored
Merge pull request #189 from tkirda/master
Do not escape xml characters when using shared strings
2 parents e1ca062 + a1861f8 commit 68838a1

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

lib/utils/shared-strings.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
*/
2323
"use strict";
2424

25-
var utils = require("./utils");
26-
2725
var SharedStrings = module.exports = function() {
2826
this._values = [];
2927
this._totalRefs = 0;
@@ -46,7 +44,6 @@ SharedStrings.prototype = {
4644
},
4745

4846
add: function(value) {
49-
value = utils.xmlEncode(value);
5047
var index = this._hash[value];
5148
if (index === undefined) {
5249
index = this._hash[value] = this._values.length;

spec/integration/workbook-xlsx-writer.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,24 @@ describe('WorkbookWriter', function() {
186186
});
187187
});
188188

189+
it('does not escape special xml characters', function () {
190+
var wb = new Excel.stream.xlsx.WorkbookWriter({filename: TEST_FILE_NAME, useSharedStrings: true});
191+
var ws = wb.addWorksheet('blort');
192+
var xmlCharacters = 'xml characters: & < > "';
193+
194+
ws.getCell('A1').value = xmlCharacters;
195+
196+
return wb.commit()
197+
.then(function() {
198+
var wb2 = new Excel.Workbook();
199+
return wb2.xlsx.readFile(TEST_FILE_NAME);
200+
})
201+
.then(function(wb2) {
202+
var ws2 = wb2.getWorksheet('blort');
203+
expect(ws2.getCell('A1').value).to.equal(xmlCharacters);
204+
});
205+
});
206+
189207
it('serializes and deserializes dataValidations', function() {
190208
var options = {filename: TEST_FILE_NAME};
191209
var wb = testUtils.createTestBook(new Excel.stream.xlsx.WorkbookWriter(options),'xlsx', ['dataValidations']);

0 commit comments

Comments
 (0)
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