You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Strip enclosing quotes before unescaping CSV fields - #1059
CsvReader.Split replaced "" with " before stripping the enclosing quotes, so a field made only of quotes lost one: """" was read as an empty string and """""" as ". MiniExcel's own export writes " and "" that way, so they did not round-trip. The enclosing quotes are now stripped first and "" is unescaped afterwards. Fields that contain any other character give the same result as before.
Test:MiniExcelCsvTests.ReadFieldsMadeOnlyOfQuotesTest exports ", "", "a", a" and "a and reads them back with hasHeaderRow: true. It fails on master ("" instead of ") and passes with this change.
Ran (Windows): dotnet test tests/MiniExcel.Csv.Tests on net8.0, net10.0 and net11.0, 90 passed each. net9.0 not run locally (no runtime here).
Summary by CodeRabbit
Bug Fixes
Fixed CSV import handling for fields containing only quotation marks or partially quoted text. These values now retain their original content when exported and imported, including when the CSV includes a header.
No actionable comments were generated in the recent review.
Walkthrough
The CSV reader now strips boundary quotes before unescaping doubled quotes. A new test checks that quote-containing values round-trip through CSV export and import.
Changes: CSV Quote-Only Field Round-Trip
Layer / File(s)
Summary
Quote parsing and round-trip test src/MiniExcel.Csv/CsvReader.cs, tests/MiniExcel.Csv.Tests/Main/MiniExcelCsvTests.cs
CsvReader.Split strips boundary quotes before unescaping doubled quotes. The new test checks that five quote-containing values import unchanged after export.
This change fixes round-tripping of CSV fields made only of double quotes, and fields with other characters are unaffected. A regression test covers the reported cases. No merge-blocking risk was found.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the change that matters: CsvReader.Split now strips enclosing quotes before unescaping doubled quotes. The raw summary and PR objectives both describe this same reordering as the fix f…
Linked Issues check
Issue #1058 requires quote-only CSV fields to round-trip. Expected: " reads back as " and "" reads back as "". The change in src/MiniExcel.Csv/CsvReader.cs (Split) now applies DoubleQuotesRege…
Out of Scope Changes check
The whole-PR diff (merge base c7fb0bd to head 261403b) changes two files. CsvReader.cs changes only the operation order in Split, which is the fix the issue requests. The test file adds ReadFieldsMade…
Full details: Title check
Explanation
The title names the change that matters: CsvReader.Split now strips enclosing quotes before unescaping doubled quotes. The raw summary and PR objectives both describe this same reordering as the fix for quote-only CSV fields (issue #1058). The title is specific and concise, and it matches the one-line source change.
Full details: Linked Issues check
Explanation
Issue #1058 requires quote-only CSV fields to round-trip. Expected: " reads back as " and "" reads back as "". The change in src/MiniExcel.Csv/CsvReader.cs (Split) now applies DoubleQuotesRegexImpl.Replace(s, "") before s.Replace("""", """). The enclosing quotes are removed first, then doubled quotes are unescaped. For """" (exported "), the result is ". For """""" (exported ""), the result is "". This matches the issue's expected behavior. The issue states that fields with other characters already round-trip. The diff keeps their result the same for the cases checked ("a", a", "a, and an embedded escaped quote). Test ReadFieldsMadeOnlyOfQuotesTest in tests/MiniExcel.Csv.Tests/Main/MiniExcelCsvTests.cs covers the quote-only cases and the other cases from the issue. The PR reports a local test run (90 passed on net8.0, net10.0, net11.0). That run is author-reported and was not re-executed here. The assessment assumes DoubleQuotesRegexImpl removes only one boundary quote at each end, as the issue's analysis implies. This was not re-read in this review.
Full details: Out of Scope Changes check
Explanation
The whole-PR diff (merge base c7fb0bd to head 261403b) changes two files. CsvReader.cs changes only the operation order in Split, which is the fix the issue requests. The test file adds ReadFieldsMadeOnlyOfQuotesTest, which supports the fix and is in scope. No unrelated changes were found in the reviewed evidence. The PR description and the raw summary report no other files changed.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Fix failing CI checks
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: acc418e1-761c-4f8e-996a-ca2e796d98e4
Commits
Reviewing files that changed from the base of the PR and between c7fb0bd and 261403b.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Stripping the enclosing quotes before unescaping "" is the right order, and the fix is minimal.
I checked it out and ran MiniExcel.Csv.Tests on net10.0 (on a tr-TR machine): 90/90 pass. With CsvReader.cs reverted to the base, ReadFieldsMadeOnlyOfQuotesTest fails as described (a " field reads back as an empty string), and the other 89 still pass.
Optional: a value that mixes the separator with quotes, such as a,"b", could be added to the same test, so the regex split and the unescape order are covered together. Not a blocker.
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
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.
Fixes #1058.
CsvReader.Splitreplaced""with"before stripping the enclosing quotes, so a field made only of quotes lost one:""""was read as an empty string and""""""as". MiniExcel's own export writes"and""that way, so they did not round-trip. The enclosing quotes are now stripped first and""is unescaped afterwards. Fields that contain any other character give the same result as before.Test:
MiniExcelCsvTests.ReadFieldsMadeOnlyOfQuotesTestexports","","a",a"and"aand reads them back withhasHeaderRow: true. It fails onmaster(""instead of") and passes with this change.Ran (Windows):
dotnet test tests/MiniExcel.Csv.Testson net8.0, net10.0 and net11.0, 90 passed each. net9.0 not run locally (no runtime here).Summary by CodeRabbit