Repository navigation
Done
Description
Follow-up to #198 / #199 (CsvQuoteMode.Strict). None of these blocked the merge; they are what the two reviews of #199 left open.
Errors
- A stray opening quote in a large file is refused as a limit, not as quoting. In strict mode an opening quote that is never closed reads on until
MaxFieldChars(16 M chars by default) and ends asTabularLimitException(limit.exceeded), saying nothing about quoting or where the field began. A small file reaches its end first and getsformat.corruptnaming the row, which is what a caller of strict mode wants in both cases. Either refuse it asformat.corruptnaming the row the field opened on, or document it onCsvQuoteMode.Strictand indocs/formats.md. - A strict refusal inside a zip or tar does not name the entry. The message says
The csv file is not valid at row N, and the whole archive fails; naming the entry (the sheet'sSource) would tell the caller which file is at fault. format.corruptvsformat.truncatedfor a file that ends inside a quoted field.corruptis documented and defensible (a forgotten quote is not a clipped upload), but decide it deliberately.
Bounds and cancellation
- The blank skip after a closing quote is unbounded and not cancellable.
EndQuotedFieldStrictlyskips whitespace in a loop that neither counts towardssinceChecknor is bounded:"x"followed by 300 M spaces is linear and allocates nothing, but a token cancelled 50 ms in took effect only after the run (~0.4 s). Count the skipped characters into the cancellation stride or bound the run byMaxFieldChars. - Dropped leading blanks still count against
MaxFieldChars. WithMaxFieldChars = 8, ten spaces and"x"throwlimit.exceededalthough the value isx. Either don't count them or document it.
Speed (strict mode only)
- The quoted fast path still stops at every delimiter and line break inside a quoted field, because it searches for the same specials as the repair mode needs. A strict-only
SearchValuesholding just the quote would read long quoted text in one run. The default path is unaffected.
Tests and small fixes
- No test reads a csv entry of a zip or tar archive strictly (only gzip is covered).
- No named test puts a strict refusal, or blanks before an opening quote, exactly on the 64 KB read-buffer boundary (the reviewer's fuzz covered it and found nothing).
- The comment in
StrictQuoteTests.ReadsQuotesAfterLeadingBlanksInLinearTimeestimates the quadratic case at "some fifteen seconds" for 60,000 quotes; it was measured at 24 s. Quote = ' '(or tab with another delimiter) together withStrictmakes the quote character also a blank. It reads sensibly in what was tried, but the options neither refuse nor document the combination.- Only space and tab are dropped around a quoted field; a non-breaking space (common in text pasted from spreadsheets) is not, so
"x,y"with an NBSP in front is split at its comma. As specified, but worth a sentence in theCsvQuoteMode.Strictremarks, or widening the blank set.
Metadata
Metadata
Assignees
Labels
No labels
Activity