Skip to content

[bugfix] Fix special cell values causing invalid files produced(#1339) #1344

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
Jun 19, 2020
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/shared-strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class SharedStrings {
constructor() {
this._values = [];
this._totalRefs = 0;
this._hash = {};
this._hash = Object.create(null);
}

get count() {
Expand Down
43 changes: 43 additions & 0 deletions spec/integration/issues/issue-1339-speciel-cell-file.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const ExcelJS = verquire('exceljs');

// this file to contain integration tests created from github issues
const TEST_XLSX_FILE_NAME = './spec/out/wb.test.xlsx';

describe('github issues', () => {
it('issue 1339 - Special cell value results invalid file', async () => {
const wb = new ExcelJS.stream.xlsx.WorkbookWriter({
filename: TEST_XLSX_FILE_NAME,
useStyles: true,
useSharedStrings: true,
});
const ws = wb.addWorksheet('Sheet1');
const specialValues = [
'constructor',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'toLocaleString',
'toString',
'valueOf',
'__defineGetter__',
'__defineSetter__',
'__lookupGetter__',
'__lookupSetter__',
'__proto__',
];
for (let i = 0, len = specialValues.length; i < len; i++) {
const value = specialValues[i];
ws.addRow([value]);
ws.getCell(`B${i + 1}`).value = value;
}
await wb.commit();
const wb2 = new ExcelJS.Workbook();
await wb2.xlsx.readFile(TEST_XLSX_FILE_NAME);
const ws2 = wb2.getWorksheet('Sheet1');
for (let i = 0, len = specialValues.length; i < len; i++) {
const value = specialValues[i];
expect(ws2.getCell(`A${i + 1}`).value).to.equal(value);
expect(ws2.getCell(`B${i + 1}`).value).to.equal(value);
}
});
});
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