[jira] Created: (SANDBOX-313) Endless loops in CSV parser

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (SANDBOX-313) Endless loops in CSV parser

ASF GitHub Bot (Jira)
Endless loops in CSV parser
---------------------------

                 Key: SANDBOX-313
                 URL: https://issues.apache.org/jira/browse/SANDBOX-313
             Project: Commons Sandbox
          Issue Type: Bug
          Components: CSV
    Affects Versions: Nightly Builds
            Reporter: Bjoern Voigt


If the input file ends with comment lines, the parser runs into an endless loop. The example shows, that the CSV parser runs into an endless loop, if the input is one comment line. '#' is the comment character here:

{noformat}
import org.apache.commons.csv.CSVStrategy;
import org.apache.commons.csv.CSVParser;
import java.io.StringReader;
import java.io.IOException;

public class TestCSV {
    public static void main(String [] args) throws IOException {
        CSVStrategy strategy=new CSVStrategy(',','"','#','\\',false,false,false,false);
       
        CSVParser parser = new CSVParser(new StringReader("# A, B\n"), strategy);
       
        System.out.println("Go into an endless loop...");
        String []line=parser.getLine();
    }
}
{noformat}

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (SANDBOX-313) Endless loops in CSV parser

ASF GitHub Bot (Jira)

     [ https://issues.apache.org/jira/browse/SANDBOX-313?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bjoern Voigt updated SANDBOX-313:
---------------------------------

    Attachment: apache-csv-endlessloop-fix.patch

The patch stops the loop, if End-of-file is detected.

> Endless loops in CSV parser
> ---------------------------
>
>                 Key: SANDBOX-313
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-313
>             Project: Commons Sandbox
>          Issue Type: Bug
>          Components: CSV
>    Affects Versions: Nightly Builds
>            Reporter: Bjoern Voigt
>         Attachments: apache-csv-endlessloop-fix.patch
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> If the input file ends with comment lines, the parser runs into an endless loop. The example shows, that the CSV parser runs into an endless loop, if the input is one comment line. '#' is the comment character here:
> {noformat}
> import org.apache.commons.csv.CSVStrategy;
> import org.apache.commons.csv.CSVParser;
> import java.io.StringReader;
> import java.io.IOException;
> public class TestCSV {
>     public static void main(String [] args) throws IOException {
>         CSVStrategy strategy=new CSVStrategy(',','"','#','\\',false,false,false,false);
>        
>         CSVParser parser = new CSVParser(new StringReader("# A, B\n"), strategy);
>        
>         System.out.println("Go into an endless loop...");
>         String []line=parser.getLine();
>     }
> }
> {noformat}

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Resolved: (SANDBOX-313) Endless loops in CSV parser

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

     [ https://issues.apache.org/jira/browse/SANDBOX-313?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Yonik Seeley resolved SANDBOX-313.
----------------------------------

    Resolution: Fixed

Thanks Bjoern, I also hit this bug with my random testing.
I've added a test and committed this.

> Endless loops in CSV parser
> ---------------------------
>
>                 Key: SANDBOX-313
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-313
>             Project: Commons Sandbox
>          Issue Type: Bug
>          Components: CSV
>    Affects Versions: Nightly Builds
>            Reporter: Bjoern Voigt
>         Attachments: apache-csv-endlessloop-fix.patch
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> If the input file ends with comment lines, the parser runs into an endless loop. The example shows, that the CSV parser runs into an endless loop, if the input is one comment line. '#' is the comment character here:
> {noformat}
> import org.apache.commons.csv.CSVStrategy;
> import org.apache.commons.csv.CSVParser;
> import java.io.StringReader;
> import java.io.IOException;
> public class TestCSV {
>     public static void main(String [] args) throws IOException {
>         CSVStrategy strategy=new CSVStrategy(',','"','#','\\',false,false,false,false);
>        
>         CSVParser parser = new CSVParser(new StringReader("# A, B\n"), strategy);
>        
>         System.out.println("Go into an endless loop...");
>         String []line=parser.getLine();
>     }
> }
> {noformat}

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.