mirror of
https://github.com/php/php-src.git
synced 2025-08-16 22:18:50 +02:00
Fix bug #53279 (SplFileObject doesn't initialise default CSV escape character).
This commit is contained in:
parent
aef6ac02f5
commit
150a741fee
2 changed files with 25 additions and 0 deletions
|
@ -274,6 +274,7 @@ static int spl_filesystem_file_open(spl_filesystem_object *intern, int use_inclu
|
||||||
|
|
||||||
intern->u.file.delimiter = ',';
|
intern->u.file.delimiter = ',';
|
||||||
intern->u.file.enclosure = '"';
|
intern->u.file.enclosure = '"';
|
||||||
|
intern->u.file.escape = '\\';
|
||||||
|
|
||||||
zend_hash_find(&intern->std.ce->function_table, "getcurrentline", sizeof("getcurrentline"), (void **) &intern->u.file.func_getCurr);
|
zend_hash_find(&intern->std.ce->function_table, "getcurrentline", sizeof("getcurrentline"), (void **) &intern->u.file.func_getCurr);
|
||||||
|
|
||||||
|
|
24
ext/spl/tests/SplFileObject_fgetcsv_escape_default.phpt
Normal file
24
ext/spl/tests/SplFileObject_fgetcsv_escape_default.phpt
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
--TEST--
|
||||||
|
SplFileObject::fgetcsv with default escape character
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$fp = fopen('SplFileObject::fgetcsv.csv', 'w+');
|
||||||
|
fwrite($fp, '"aa\"","bb","\"c"');
|
||||||
|
fclose($fp);
|
||||||
|
|
||||||
|
$fo = new SplFileObject('SplFileObject::fgetcsv.csv');
|
||||||
|
var_dump($fo->fgetcsv());
|
||||||
|
?>
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
unlink('SplFileObject::fgetcsv.csv');
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
array(3) {
|
||||||
|
[0]=>
|
||||||
|
string(4) "aa\""
|
||||||
|
[1]=>
|
||||||
|
string(2) "bb"
|
||||||
|
[2]=>
|
||||||
|
string(3) "\"c"
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue