#78 Incorrect parsing for quote followed by space

open
nobody
None
5
2011-09-30
2011-09-30
Anonymous
No

This is NOT a duplicate of bug ID: 3217444 !

The following content is not parsed correctly:

[code]
"First Name,Last Name" ,Address
[/code]

The results is as follows:
first element:First, Name"
second element:Address

Note the the space after the quote and before the comma separator. Once this space is removed, the parser works fine.

Related

Code: code

Discussion


  • Anonymous
    2011-09-30

    The result is actually like this:

    First, Name"
    Last Name

    The quote is not expected there.

     

  • Anonymous
    2011-10-01

    It looks like at line #239 in CSVParser, the quote was appended to ythe returned value without checking the value of the variable 'inQuotes'.

    At the first glance, the code should be like this:

    [CODE]
    if (ignoreLeadingWhiteSpace && sb.length() > 0 && isAllWhiteSpace(sb)) {
    sb.setLength(0); //discard white space leading up to quote
    } else {
    if (!inQuotes) {
    sb.append(c);
    //continue;
    }
    }
    [/CODE]