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
14 changes: 0 additions & 14 deletions .changeset/csv-binary-encoding.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/inspect.md

This file was deleted.

7 changes: 0 additions & 7 deletions .changeset/package-scan-active-content.md

This file was deleted.

2 changes: 1 addition & 1 deletion apps/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"test": "vitest run"
},
"dependencies": {
"javascript-excel": "2.4.0"
"javascript-excel": "2.5.0"
},
"devDependencies": {
"happy-dom": "21.0.4",
Expand Down
2 changes: 1 addition & 1 deletion examples/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"check": "tsc -p tsconfig.json"
},
"dependencies": {
"javascript-excel": "2.4.0"
"javascript-excel": "2.5.0"
},
"devDependencies": {
"@types/node": "22.20.5",
Expand Down
2 changes: 1 addition & 1 deletion examples/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"check": "tsc -p tsconfig.json"
},
"dependencies": {
"javascript-excel": "2.4.0",
"javascript-excel": "2.5.0",
"react": "19.3.1",
"react-dom": "19.3.1"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/snippets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"check": "tsc -p tsconfig.json"
},
"dependencies": {
"javascript-excel": "2.4.0"
"javascript-excel": "2.5.0"
},
"devDependencies": {
"@types/node": "22.20.5",
Expand Down
2 changes: 1 addition & 1 deletion examples/vanilla/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"check": "tsc -p tsconfig.json"
},
"dependencies": {
"javascript-excel": "2.4.0"
"javascript-excel": "2.5.0"
},
"devDependencies": {
"typescript": "7.0.2",
Expand Down
2 changes: 1 addition & 1 deletion examples/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"check": "tsc -p tsconfig.json"
},
"dependencies": {
"javascript-excel": "2.4.0",
"javascript-excel": "2.5.0",
"vue": "3.5.45"
},
"devDependencies": {
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions packages/javascript-excel/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# javascript-excel

## 2.5.0

### Minor Changes

- ad9bfee: `readCsv` can now tell whether an upload is text, within limits. All new options are off by default, so files 2.4 read are read the same way.

- `rejectBinary: true` scans the decoded text once, before any record is parsed, and refuses a control character that text files do not contain with `FormatError` `CSV_BINARY_INPUT` (`details: { offset, byteOffset?, codePoint, encoding? }`, never file text). Refused: U+0000–U+0008, U+000E–U+001A, U+001C–U+001F and DEL; TAB, LF, CR, VT, FF and ESC are allowed. U+0080–U+009F are refused only in text decoded as Windows-1252, where they come from its undefined bytes. A PNG, PDF or zip renamed `.csv` is refused at its first control byte.
- `encoding: 'auto'`: a UTF-8 or UTF-16 BOM still wins; otherwise strict UTF-8, then strict Windows-1252 (0x81, 0x8D, 0x8F, 0x90 and 0x9D are not text). Bytes that are neither, or invalid after their BOM, throw `FormatError` `CSV_INVALID_ENCODING` (`details: { encodings, byteOffset? }`) instead of being replaced. UTF-16 without a BOM is not guessed.
- The result has a new `encoding` field for byte input: the encoding used, by its WHATWG name (`'utf-8'`, `'utf-16le'`, `'utf-16be'`, `'windows-1252'`, …). `importDataset` reports the one `'auto'` chose in `meta.encoding`.
- `maxInputBytes` refuses larger binary input with the same `LimitError` as `ReadLimits.maxInputBytes` for xlsx, and is validated the same way (a positive number; `null` is a `TypeError`); a `Blob` is checked by its size before it is read. It does not apply to string input. `importDataset` applies `limits.maxInputBytes` to CSV when it is given (CSV stays unlimited by default).
- `keepRows: false` (also for `parseCsv`) parses and checks every record, with the same limits, strict mode and warnings, but keeps none, so a check of a large upload holds only its bytes, its text and one record.
- `importDataset` takes `rejectBinary` for CSV input, and the worker client's `parseCsv` passes the new options through. With `limits.maxInputBytes` given, `importDataset` checks a `Blob`'s size before reading it, for every format. For uploads that must be CSV, pass `format: 'csv'`: with format detection a zip or xlsx input is read as a workbook and does not go through `rejectBinary`, which only checks that the input decodes to text (HTML, script or polyglot content passes).
- `readCsv` results for byte input gain an `encoding` key, so deep-equal comparisons of a whole result (`toEqual`) see one more key.
- `ExcelErrorCode` gains `CSV_BINARY_INPUT` and `CSV_INVALID_ENCODING`: an exhaustive `switch` with a `never` default needs the two new cases.
- 39e324a: New `inspect(input, { limits, signal })` in `javascript-excel/read` checks an `.xlsx`, `.xlsm`, `.xltx` or `.xltm` file part by part without building its cells, for servers and browsers that must accept or refuse an upload without reading it into the model. Under the same limits it refuses every file `read` refuses, with the same error class, code and details (zip and reader limits, encryption, CFB and other formats, `NOT_XLSX`, `XML_DTD_FORBIDDEN`, malformed XML in the parts `read` parses, every sheet to its last row), and it returns `read`'s `UNSUPPORTED_PART` warnings with their `partKinds` (VBA, macro sheets, external links, connections, OLE objects, query tables, …), the format, the worksheets with their cell counts (as `maxCells` counts them) and used ranges, and the counts of parts, inflated bytes, cells and shared strings. It also inflates every part `read` never opens (zip limits and CRC-32 apply) and searches its bytes for `<!DOCTYPE` (ASCII-compatible, UTF-16 and UTF-32 forms, whatever the part's name or content type, so a declaration inside an XML comment or an embedded file is refused too), and it refuses an XML part, including the parts `read` parses, whose byte order mark, first bytes or complete XML declaration show any encoding but UTF-8 or UTF-16, whose declaration does not follow the XMLDecl grammar, or that has a `<?xml` declaration anywhere but at its very start (`XML_MALFORMED`); so it can refuse files `read` accepts. Set `maxItems` with it: the styles table and the defined names are held, bounded by that limit. It keeps no cells, no shared strings and no more than 8 MiB of shared-formula text per sheet under any `maxCellTextLength` (a master's text waits only until a copy needs it; then a few numbers per master, and with a small limit per relative reference, all counted against `maxItems`): on a 19.8 MiB file of 3,420,000 cells its peak heap was about 30 MB, against about 410 MB for `read`, and it checks that file with the old generation limited to 32 MB. `read` is unchanged.
- 170129d: `read` (and `importDataset`, which passes read warnings on) now walks the whole relationship graph of the package and reports more content it does not read as `UNSUPPORTED_PART`, with six new `partKind` values: `'activeX'` (ActiveX controls), `'embeddedPackage'` (a `package` relationship, such as a `.docx` embedded under `xl/embeddings/`), `'customUI'` (a ribbon customisation: the root `ui/extensibility` relationship of Office 2007 or 2010), `'webExtension'` (Office web add-ins), `'invalidPartName'` (a zip entry name, relationship target or Override PartName OPC forbids: `%2F` or `%5C` in a segment, a percent-encoded dot segment, a segment ending in a dot, a target naming a relationships part or `[Content_Types].xml`, a target or PartName over 196,605 characters, which is not resolved; or a `<Relationship>` without `Id` or `Target`, which the model still ignores) and `'unreferencedPart'` (a part no relationship reaches, such as a `vbaProject.bin` or an executable placed in the zip). The last two come as one warning each, with every name in a new `parts` field on the warning (bounded by `maxEntries`). Nothing is exempt by name: discarded parts Office 2007/2010 left under `[trash]/` are reported too; a consumer that accepts them can check that every name in `parts` starts with `[trash]/`. The scan also finds `'oleObject'`, `'vbaProject'` (now also attached toolbars and VBA signatures), `'externalLink'`, `'connections'`, `'queryTable'` and `'macrosheet'` where they were not reported before: under a drawing, under a table, or on a sheet left out by the `sheets` option. Excel 4 macro sheets with Microsoft's `xlMacrosheet` and `xlIntlMacrosheet` relationship types are now reported as `'macrosheet'`. Relationship types are compared case-insensitively, and a part with the content type of an ActiveX control, OLE object, VBA project, macro sheet, web add-in or embedded Office file (documents, templates, add-ins, slides) is reported as that kind whatever relationship reaches it; equivalent Overrides in `[Content_Types].xml` are all checked. Drawings, images, comments and the other passive kinds are reported as before. Every relationships part in the zip is classified, also one whose owner nothing reaches. The scan reads only relationships parts, within the existing zip and XML limits, never inflates the parts it reports, and consults the signal throughout; a relationships part that is not well-formed XML is reported as unreferenced instead of failing the read. Existing warnings keep their shape; a `switch` over `ExcelPartKind` needs a `default` branch, as documented. The test corpus (files from LibreOffice and openpyxl, and every file of the conformance corpus this library writes) gives no new warnings.

Behaviour changes against 2.4.0: part names are compared in OPC canonical form (percent-escapes decoded once, as UTF-8, on both sides; `%2F`, `%5C`, `%25` and invalid bytes kept encoded), so percent-encoded zip entry names are now found where 2.4.0 reported `MISSING_PART` or `NOT_XLSX`, while a target matched to an entry only because 2.4.0 decoded the target and not the entry name (a literal `%` spelled differently on the two sides) no longer matches. Two zip entries with equivalent names (for example `a b` and `a%20b`) now throw `ZIP_INVALID`, as names that differ only in case already did. Because the scan parses every relationships part in the zip, a DTD or an over-deep XML in one of them (also under a sheet that is not read, or in an orphan relationships part) now throws `XML_DTD_FORBIDDEN` or `LIMIT_EXCEEDED`; 2.4.0 read such a file. A relationship target or Override PartName longer than 196,605 characters is not resolved and is reported as `'invalidPartName'`; the length is checked before dot segments are resolved, so a part reachable only through such a padded target (for example 200 KB of `./` before `worksheets/sheet1.xml`) is now missing for `read`, where 2.4.0 read it.

## 2.4.0

### Minor Changes
Expand Down
Loading