saleemno1 opened a new pull request, #625:
URL: https://github.com/apache/commons-csv/pull/625

   Thanks for maintaining this! `ExtendedBufferedReader.peek(char[])` and 
`read(char[], int, int)` inherit a buffered read that returns as soon as the 
source reports it is not ready, so a `Reader` backed by a socket or a pipe 
hands back a short read and the delimiter lookahead is matched against a 
half-filled buffer.
   
   Two things go wrong once the buffer is short:
   
   - `Lexer.isDelimiter` / `isEscapeDelimiter` compare every slot, so the 
still-zeroed tail makes a multi-character delimiter that is really present look 
like ordinary text. Parsing `a[|]b` with delimiter `[|]` yields one field 
`a[|]b` from a chunked reader and two fields `a`, `b` from a `StringReader` for 
the same bytes, which is a parser differential if the split feeds any filtering 
or routing decision.
   - `CSVFormat.printWithEscapes(Reader, Appendable)` builds its lookahead the 
same way, so printing the single value `x[|]y` from a chunked reader writes the 
delimiter unescaped and the record reads back as two fields.
   
   Both call sites share the same reader, so the loop lives there rather than 
in each caller. Added a regression test at the reader level and one at the 
parser level; both fail without the change. `mvn` is green including the 
coverage gate.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to