Repository navigation
Conversation
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.
BracketAwareCsvParserjoins fields until their(and)balance, sokeyMatch(/a, /b)stays one field. But it counts brackets aftercsv-parsehas removed the quotes, so a quoted field is joined too. AndsavePolicywrites such a field without quotes. So a policy with an unbalanced bracket in a field can be saved, but then the file fails to load or loads a different policy:alice, data(, readp, alice, data(, readUnmatched brackets in policy linebob, a), (bp, bob, a), (bbob, a),(b(two fields joined into one)g, carol, :)g, carol, :)Writing the field in quotes by hand (
p, alice, "data(", read) does not help either, because the quotes are gone before the count.Changes:
BasicCsvParser.parseFieldsreturns each field withquoted(from thecsv-parsecast context).parsereturns the same strings as before.BracketAwareCsvParserdoes not count brackets in quoted fields. A custom base parser keeps the old behavior.FileAdapter.escapeCsvalso quotes a field whose brackets do not balance. Balanced fields likekeyMatch(/a, /b)are written as before.Tests: a round trip test in
fileAdapter.test.tsand three lines inhelper.test.ts(two quoted bracket fields, plus thekeyMatch(/a, /b)join that must keep working). The new tests fail before the change.npx jest: 269 passed; tsc, eslint and prettier are clean.