Repository navigation
Conversation
When parse_quotable_robust found a field longer than max_field_size, it skipped only to the end of the physical line. If a later quoted field in the record spanned lines, the rest of the record was parsed as the next row. Skip the rest of the record with parse_column_value, so the next row and CSV#line are correct. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
How about doing this in all parse modes like #382? |
Author
|
Closing in favor of #382. Thank you. |
kou
added a commit
that referenced
this pull request
Nov 1, 2026
GitHub: Fix GH-381 A max_field_size error skipped only the rest of the physical line. In parse_quotable_robust, the rest of a record that has a quoted field spanning lines was returned as the next row or raised another error. In parse_quotable_loose and parse_no_quote, the line was already read, so the next line was skipped too, and CSV#line raised TypeError when the error was in the first row. Validate field sizes in emit_row instead. All parsers call it after reading the whole record, so nothing needs to be skipped and CSV#line returns the whole broken record. If the record has another error after the long field, such as an unclosed quoted field, that error is raised instead, as it is without max_field_size. The field_size_limit document said that it limits how much CSV reads ahead and prevents DoS attacks. It wasn't true even with the old line based parser: it read a whole line without limit and stopped reading only lines of an unclosed quoted field. The current parser doesn't stop reading at all. Remove it from the document and add a document for max_field_size that says it doesn't limit how much CSV reads. Reported by William T. Nelson. Thanks!!! Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After a
max_field_sizeerror, the field-scanning parser (parse_quotable_robust) skips only to the end of the physical line. If a later quoted field in the record spans lines, the rest of the record comes back as the next row:Without
liberal_parsing, the field-scanning parser is used after a row with a quoted field that spans lines. There, the rest of the record raisesIllegal quotingon the nextshift.Fix
parse_quotable_robustpasses a block tovalidate_field_size, which calls it in place ofignore_broken_line. The block calls the newignore_broken_record, which reads the remaining fields of the record withparse_column_valueand then the row end.CSV#lineis then the whole broken record, and the line number goes up by one. The line-splitting parser (parse_quotable_loose) andparse_no_quoteare unchanged.If the rest of the record is malformed,
ignore_broken_recorddrops the rest of the physical line, and the error is still the field size error. An unclosed quote after the long field now reads to the end of the input, as it does withoutmax_field_size. Onmain,abcde,"x\nc,d\nwithliberal_parsingreturned["c", "d"]after the error.