Skip to content

Unclosed quote is auto-closed at the end of file by the parser? #173

@dmitry-workato

Description

@dmitry-workato

Hey, could someone check if this is expected behaviour:

This code:

import de.siegmar.fastcsv.reader.CsvReader;
import de.siegmar.fastcsv.reader.StringArrayHandler;

String csv = """
                col1,col2
                "val1,val2
                val3,val4
                """;
        var reader = CsvReader.builder()
                .fieldSeparator(',')
                .quoteCharacter('"')
                .skipEmptyLines(true)
                .allowExtraFields(true)
                .allowMissingFields(true)
                .allowExtraCharsAfterClosingQuote(false)
                .trimWhitespacesAroundQuotes(true)
                .maxBufferSize(1024).build(StringArrayHandler.of(), asStream(csv), StandardCharsets.UTF_8);
        Iterator<String[]> it = reader.stream().iterator();
        while (it.hasNext()) {
            String[] row = it.next();
            System.out.println("Line: " + String.join(",", row));
        }

Current Behavior

Outputs:

Line: col1,col2
Line: val1,val2
val3,val4

The unclosed quote makes parser consume all bytes till the end of the file as one column value ...

Expected Behavior

I would expect parser fail on the unclosed quote.

Steps to Reproduce

Run the java snippet

Additional Context

  • Operating system: macOS
  • FastCSV version: 4.1.0
  • Java version: 25

Many thanks in advance for any help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions