#2406 closed defect (wontfix)
CSVReadParseLine doesn't properly handle double-backslash
Reported by: | dstahlke | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | default | Version: | 1.5.1 |
Severity: | normal | Keywords: | CSVReadParseLine CSV quote backslash |
Cc: |
Description
The following line breaks the CSV parser:
1,2,"abc
"" def"
The problem is that CSVReadParseLine has logic that simply checks to see whether there is a backslash in front of a quote but does not have logic that interprets double-backslashes. The example given is then interpreted as having an odd number (three) of quotes.
As a test case, run ogrinfo on the attached file.
Attachments (1)
Change History (4)
by , 16 years ago
comment:1 by , 16 years ago
Hum, this is a bit a limit case for CSV...
In the documentation of the CSV driver, we advertize that quotes in string should be escaped with double quotes. But in the code, we also seem to have the possibility that quotes are escaped with a blackslash (documentation for CSVFindNextLine()). However escaping quote with blackslash doesn't work very well, even on this "simple" case :
lon,lat,label 1,2,"abc \"def" 3,4,"xyz"
The result is :
OGRFeature(bad):1 lon (String) = 1 lat (String) = 2 label (String) = abc \def OGRFeature(bad):2 lon (String) = 3 lat (String) = 4 label (String) = xyz
So the quote got lost.
I think we also definitely don't want to escape backslash with backslash...
comment:2 by , 9 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
This is so much a corner case and it has been open for 7 years that I think it has been enough. Reopen with some real world use case if needed.
The result that Even wants comes from this peculiar CSV
lon,lat,label 1,2,"abc """def"" 3,4,"xyz"
comment:3 by , 9 years ago
Seems to be related to #5318 so perhaps closing as duplicate would have been a better fit.
Running ogrinfo on this file doesn't give two features as expected