fix(csv): strip leading byte-order mark in CsvParseStream#7183
Open
LeSingh1 wants to merge 1 commit into
Open
Conversation
parse() already strips a leading BOM from its input string, but CsvParseStream left it intact. When a UTF-8 CSV file starts with a BOM (common output of tools like Excel), the first field name would arrive as "name" instead of "name", corrupting headers and key lookups. StreamLineReader now strips the BOM from the first line it reads, matching the existing parse() behaviour exactly.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7183 +/- ##
==========================================
- Coverage 94.57% 94.57% -0.01%
==========================================
Files 636 637 +1
Lines 52142 52159 +17
Branches 9401 9403 +2
==========================================
+ Hits 49315 49328 +13
- Misses 2249 2254 +5
+ Partials 578 577 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
The synchronous
parse()function already strips a leading UTF-8byte-order mark (U+FEFF) from its input, but
CsvParseStreamdid not.When a CSV file begins with a BOM -- common output from Excel and other
Windows tools -- the first field name arrives as
"name"insteadof
"name". That corrupts header-based lookups silently:The fix adds a
#firstLineflag toStreamLineReaderand strips theBOM from the first line it reads, exactly matching what
parse()doesvia its
BYTE_ORDER_MARKconstant.Two new tests cover the regression: one for plain
string[][]output andone for
skipFirstRow: true(object output, where the BOM corrupts theheader key).