Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,21 @@ describe('Excel Exporter', () => {
await wrapper.verifyDataFilesContent(actualData.contactsDataSkippedColumnContent);
});

it('should not fail when data contains null characters (#14944).', async () => {
options.columnWidth = 50;
const wrapper = await getExportedData([
'Terrance\u0000Orta',
'Richard Mahoney\x00LongerName',
'Donna\0Price',
'Lisa Landers',
'Dorothy H. Spencer'
], options);

wrapper.verifyStructure();
await wrapper.verifyTemplateFilesContent();
await wrapper.verifyDataFilesContent(actualData.noHeadersStringDataWithNullChars);
});

const getExportedData = (data: any[], exportOptions: IgxExcelExporterOptions) => {
const result = new Promise<ZipWrapper>((resolve) => {
exporter.exportEnded.pipe(first()).subscribe((value) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1935,4 +1935,22 @@ export class FileContentData {

return this.createData();
}

public get noHeadersStringDataWithNullChars() {
this._sharedStringsData = `count="6" uniqueCount="6"><si><t>Column1</t></si><si><t>TerranceOrta</t></si>` +
`<si><t>Richard MahoneyLongerName</t></si><si><t>DonnaPrice</t></si><si><t>Lisa Landers</t></si><si><t>` +
`Dorothy H. Spencer</t></si>`;

this._tableData = `ref="A1:A6" totalsRowShown="0"><autoFilter ref="A1:A6"/><tableColumns count="1">` +
`<tableColumn id="1" name="Column1"/></tableColumns>`;

this._worksheetData = `<dimension ref="A1:A6"/><sheetViews><sheetView tabSelected="1" workbookViewId="0"></sheetView>` +
`</sheetViews><sheetFormatPr defaultRowHeight="15" x14ac:dyDescent="0.25"/><cols><col min="1" max="1" ` +
`width="50" customWidth="1"/></cols><sheetData><row r="1"><c r="A1" t="s"><v>0</v></c></row><row r="2">` +
`<c r="A2" t="s"><v>1</v></c></row><row r="3"><c r="A3" t="s"><v>2</v></c></row><row r="4"><c r="A4" t="s"><v>3</v>` +
`</c></row><row r="5"><c r="A5" t="s"><v>4</v></c></row><row r="6"><c r="A6" t="s"><v>5</v></c></row></sheetData>`;

return this.createData();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ export class ExportUtilities {
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&apos;');
.replace(/'/g, '&apos;')
// Bug #14944 - Remove the not supported null character (\u0000, \x00)
.replace(/\x00/g, '');
}
}
}
Loading