CSV Sample File Was Miscoded (#1489)

File author erroneously assumed that backslash was used to escape
quotes in CSV; in fact, doubling the quote is used for escape.
The test still worked, but mainly because the content of the cell
with the escape wasn't tested. The file is now fixed, and
a new test added.
This commit is contained in:
oleibman 2020-05-24 03:57:39 -07:00 committed by GitHub
parent 9947de3b89
commit 41b95c1542
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 16 deletions

View File

@ -200,6 +200,37 @@ EOF;
self::assertEquals($expected, $sheet->getCell('B3')->getValue()); self::assertEquals($expected, $sheet->getCell('B3')->getValue());
} }
public function testLineBreakEscape(): void
{
$reader = new Csv();
$spreadsheet = $reader->load('tests/data/Reader/CSV/line_break_in_enclosure_with_escaped_quotes.csv');
$sheet = $spreadsheet->getActiveSheet();
$expected = <<<EOF
This is a "test csv file"
with both "line breaks"
and "escaped
quotes" that breaks
the delimiters
EOF;
self::assertEquals($expected, $sheet->getCell('B3')->getValue());
}
public function testUtf32LineBreakEscape(): void
{
$reader = new Csv();
$reader->setInputEncoding('UTF-32LE');
$spreadsheet = $reader->load('tests/data/Reader/CSV/line_break_escaped_32le.csv');
$sheet = $spreadsheet->getActiveSheet();
$expected = <<<EOF
This is a "test csv file"
with both "line breaks"
and "escaped
quotes" that breaks
the delimiters
EOF;
self::assertEquals($expected, $sheet->getCell('B3')->getValue());
}
public function testSeparatorLine(): void public function testSeparatorLine(): void
{ {
$reader = new Csv(); $reader = new Csv();

Binary file not shown.
Can't render this file because it contains an unexpected character in line 2 and column 24.

View File

@ -1,21 +1,21 @@
Name,Copy,URL Name,Copy,URL
Test,"This is a \"test csv file\" Test,"This is a ""test csv file""
with both \"line breaks\" with both ""line breaks""
and \"escaped and ""escaped
quotes\" that breaks quotes"" that breaks
the delimiters",http://google.com the delimiters",http://google.com
Test,"This is a \"test csv file\" Test,"This is a ""test csv file""
with both \"line breaks\" with both ""line breaks""
and \"escaped and ""escaped
quotes\" that breaks quotes"" that breaks
the delimiters",http://google.com the delimiters",http://google.com
Test,"This is a \"test csv file\" Test,"This is a ""test csv file""
with both \"line breaks\" with both ""line breaks""
and \"escaped and ""escaped
quotes\" that breaks quotes"" that breaks
the delimiters",http://google.com the delimiters",http://google.com
Test,"This is a \"test csv file\" Test,"This is a ""test csv file""
with both \"line breaks\" with both ""line breaks""
and \"escaped and ""escaped
quotes\" that breaks quotes"" that breaks
the delimiters",http://google.com the delimiters",http://google.com

Can't render this file because it contains an unexpected character in line 2 and column 18.