Expand description
The single CSV cell escaper for this crate — RFC 4180 quoting plus the
CWE-1236 formula-injection guard, pinned to the TypeScript half by
tests/csv_cell_parity.rs.
THE CSV cell escaper for this repository’s Rust.
Every Rust producer of CSV calls [escape_csv_cell] and nothing else. The
TypeScript half lives in packages/export/src/csv-cell.ts; both are pinned
to the shared vectors in tests/fixtures/csv_cell_vectors.json by
tests/csv_cell_parity.rs and csv-cell.parity.test.ts, so the two
languages cannot drift apart silently.
Two things it does that the previous hand-rolled copies did not:
- The formula-injection guard (CWE-1236) looks past leading invisibles.
Testing the trigger anchored at offset 0 — as this crate did — means a
BOM, ZWSP, LRM, NBSP or U+2028 in front of
=walks straight through, because none of those stops a spreadsheet evaluating the cell. - It looks past them without DELETING them, so a benign
" Wall A"keeps its spaces (RFC 4180 §2.4: “Spaces are considered part of a field and should not be ignored”).
Structs§
- CsvCell
Options - Options for
escape_csv_cell.
Functions§
- escape_
csv_ cell - Escape one CSV cell: neutralise spreadsheet formula injection (CWE-1236), then apply RFC 4180 quoting.
- is_
invisible_ prefix - Is
can invisible that can hide a formula trigger behind it? - is_
padding - Whitespace for the opt-in
CsvCellOptions::quote_whitespace_paddedrule.