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
With an escape character set and no quote character (or QuoteMode.NONE), CSVFormat.printWithEscapes escapes the delimiter, CR, LF, the escape character and (since #609) the quote character, but never a comment marker. A value whose first character is the configured comment marker is written verbatim, so CSVPrinter emits a record that its own CSVParser reads back as a comment and silently drops. CSVFormat.DEFAULT.builder().setQuote(null).setEscape('\').setCommentMarker(';').get() prints ;foo for the value ;foo, and re-parsing that output yields zero records. Found round-tripping printer output back through the parser.
The escape condition is the right place to fix it, next to where the delimiter, escape char and quote char are already handled. The change escapes the comment marker when it is the first character of the value, in both printWithEscapes overloads (CharSequence and Reader). This is the escape-mode counterpart to #610, which protected the comment marker only in the MINIMAL quoting path and left the escape paths out.
I used AI to create any part of, or all of, this pull request. Which AI tool was used to create this pull request, and to what extent did it contribute?
Run a successful build using the default Maven goal with mvn; that's mvn on the command line by itself.
Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible, but it is a best practice.
Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
Each commit in the pull request should have a meaningful subject line and body. Note that a maintainer may squash commits during the merge process.
ran mvn here and the only failure is testGetBytePositionMultiCharacterDelimiterWithSupplementaryCharacter, which fails on master too, not from this PR. the Refactor delimiter in test commit (a1cf4f2) set the expected value to "a" + delimiter + "b\n".getBytes(UTF_8).length. .length binds before +, so that evaluates to the string "ax😀2" rather than the byte count 8; the prior "ax😀b\n".getBytes(UTF_8).length was correct. my change and its two tests are green once that line is restored. want me to drop the one-line fix into this PR, or will you patch master?
rebased onto master, so the revert of a1cf4f2 is in the branch now and the byte-position test is green again. ran mvn with no args locally, full build passes.
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.
With an escape character set and no quote character (or
QuoteMode.NONE),CSVFormat.printWithEscapesescapes the delimiter,CR,LF, the escape character and (since #609) the quote character, but never a comment marker. A value whose first character is the configured comment marker is written verbatim, soCSVPrinteremits a record that its ownCSVParserreads back as a comment and silently drops.CSVFormat.DEFAULT.builder().setQuote(null).setEscape('\').setCommentMarker(';').get()prints;foofor the value;foo, and re-parsing that output yields zero records. Found round-tripping printer output back through the parser.The escape condition is the right place to fix it, next to where the delimiter, escape char and quote char are already handled. The change escapes the comment marker when it is the first character of the value, in both
printWithEscapesoverloads (CharSequenceandReader). This is the escape-mode counterpart to #610, which protected the comment marker only in theMINIMALquoting path and left the escape paths out.mvn; that'smvnon the command line by itself.