fix(core): handle escaped quotes in CSV parser#33
Open
AnanthuNarashimman wants to merge 1 commit intoblackboxaicode:mainfrom
Open
fix(core): handle escaped quotes in CSV parser#33AnanthuNarashimman wants to merge 1 commit intoblackboxaicode:mainfrom
AnanthuNarashimman wants to merge 1 commit intoblackboxaicode:mainfrom
Conversation
Fixes incorrect parsing of CSV fields containing double quotes. Includes unit tests.
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.
Description
This PR fixes a critical bug in the custom
parseCSVLinelogic where double quotes appearing inside a quoted field (escaped as"") were incorrectly interpreted as the end of the field.The Bug:
Previously, the parser simply toggled the
inQuotesstate whenever it encountered a quote. This caused inputs like"foo""bar"to be parsed as['foobar']instead of['foo"bar'], resulting in silent data corruption.The Fix:
I have updated the
parseCSVLinefunction to include a look-ahead check. Now, when a quote character is encountered inside a quoted field:") and skips the next character.Linked Issue
Fixes #23
Type of Change
How Has This Been Tested?
I have added a new test suite in
packages/core/src/tools/read-data-file.test.tsto verify the fix and prevent regressions.Test Coverage:
"He said ""Hello"""parse correctly asHe said "Hello".npm run testand confirmed all 13 new test cases pass.Checklist