A hostile file could abort any process that opens it: a cell formula of a
million `%` (`1%%%…`) or a 200,000-term sum parsed into trees deep enough to
overflow the stack when printed, saved, evaluated or dropped, even in release
builds. Postfix operators (`%`, invoking a result) built their nesting in a
loop that the 256-level limit did not see.
- `parse` refuses formula text longer than Excel's 8,192 characters
(`MAX_FORMULA_LEN`, counted in characters, the leading `=` excluded). This
also bounds the depth of the left-deep trees long operator chains build.
- Each postfix `%` and each call of a result counts towards the nesting limit.
- A file's formula that is refused keeps its text and cached value, as other
unparsable formulas do.
Regression tests: formula (small-stack thread: long `%`, invoke and operator
chains are errors; the limit counts characters, not bytes) and xlsx
(`hostile_formula_text_does_not_overflow_the_stack`: open, save and drop a
workbook with such formulas and a defined name on a 1 MiB stack). Both abort
with a stack overflow without the fix.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
From 1E+15, CSV export writes the shortest round-trip digits, not &'s 15 digits.
'Every digit' now applies only to integers below 1e16.
The open/save round-trip claim is narrowed to files GridCraft wrote. The doc
now lists what a foreign CSV loses on its first save: 16-17-digit decimals are
cut to 15 digits, and scientific input is rounded to its 0.00E+00 format.
The 21-character switch is Excel-verified only for positive 15-digit
mantissas. Shorter mantissas from 1E-6 to 1E-9 and negatives are marked as
inferred, and the doc states the sign isn't counted. The function-parity
'was' value is corrected to main's 0.00000001.
The 2^53 cutoff turned exact 16-digit integers (9007199254740992, 9007199254740994) into
9.00719925474099E+15. A General number is now written with &'s 15 digits but never with an
exponent: reopening a CSV gives a scientific number a 0.00E+00 format that rounds it on the next
save. 1E+15 and up are written as the shortest round-trip digits (every integer below 1e16
exactly, main's output above), small numbers as their 15 digits in full.
Excel caches IMCSCH("13+5j") as 1.28233995888454E-06 and IMSECH("7+25j")'s imaginary part as
0.000241377759972715: below 1, a 15-digit decimal longer than 21 characters is written in
scientific notation. 9.99999999999999E-9&"" now gives 9.99999999999999E-09, not
0.00000000999999999999999. Affects every number-to-text conversion (&, CONCAT, TEXTJOIN, IM
functions, formula printing, labels).
Writing every General number as & converts it rounded 16-digit integers such as card and order numbers to 1.23456789012346E+15, so opening a CSV and saving it again changed the data. Integers that f64 holds exactly (|x| < 2^53) are now written with all their digits, as before; larger integers and non-integers keep the 15-significant-digit & text.
number_to_text picked the decimal branch for values in [999999999999999.5, 1e15) and then rounded them up to the 16-digit integer 1000000000000000. It now rounds to 15 significant digits first and chooses the notation from the rounded exponent, so those values read 1E+15 (and -1E+15).
Main writes plain General with Rust's shortest round-trip (0.30000000000000004,
100000000000000000000) and still narrows coloured/sectioned General and numbers in
Text cells to the 11-character cell display (1.24412E+11). Export now formats through
numfmt's format_value_full, which writes General as number_to_text does, replacing
io.rs's plain-General special case. Docs: merge the duplicate CSV/text rows.
Brings the branch up to upstream's main (59 more commits). One conflict:
- docs/ui-parity.md: every line of both sides is kept, as upstream's own
merges keep them, in the order of their dates, newest first (upstream
has a change of the 13th now, which goes above this one of the 12th).
Gate: all eight steps, 1580 tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>