Skip to content

Issue when escape characters are split over stream chunks #17

@alirussell

Description

@alirussell

Hi,

im running into an issue where an escape then the following enclose character (both in my case a double quote "), are split over two sequential chunks in a stream..

In this simple bit of code for example:

var Parser = require('csv-stream/lib/parser');

var p = new Parser({
    escapeChar : '"',
    enclosedChar : '"'
});

p.parse('"..."');
p.parse('"quoted"""');

the full string is actually "...""quoted""", but because the two characters are split, it breaks this line (https://github.com/lbdremy/node-csv-stream/blob/master/lib/parser.js#L52) because it doesn't have access to the next character in the full string to determine if its actually an enclose character.

A suggested fix would be to keep track of if we are currently "escaping" between chunks, and treat the first character of the next chunk a bit differently.

I will create a PR for the fix

Thanks

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