]> granicus.if.org Git - php/commitdiff
Fix bug #53279 (SplFileObject doesn't initialise default CSV escape character).
authorAdam Harvey <aharvey@php.net>
Tue, 9 Nov 2010 14:53:23 +0000 (14:53 +0000)
committerAdam Harvey <aharvey@php.net>
Tue, 9 Nov 2010 14:53:23 +0000 (14:53 +0000)
NEWS
ext/spl/spl_directory.c
ext/spl/tests/SplFileObject_fgetcsv_escape_default.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 7f8fb0a9abc86ea13b82f4da9f8bcc8ae4d3b1dc..be5c46ce4d05ecd6fe07f208049605d2781ad485 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -55,6 +55,8 @@
 - Fixed the filter extension accepting IPv4 octets with a leading 0 as that
   belongs to the unsupported "dotted octal" representation. (Gustavo)
 
+- Fixed bug #53279 (SplFileObject doesn't initialise default CSV escape
+  character). (Adam)
 - Fixed bug #53273 (mb_strcut() returns garbage with the excessive length parameter). (CVE-2010-4156) (Mateusz Kocielski, Pierre, Moriyoshi)
 - Fixed bug #53248 (rawurlencode RFC 3986 EBCDIC support misses tilde char).
   (Justin Martin)
index 98e810ab042de1d2cf0c8c86ebb910d9dea430b1..f4c61fd5c160f99a5024218fe605b0569c8303ff 100755 (executable)
@@ -275,6 +275,7 @@ static int spl_filesystem_file_open(spl_filesystem_object *intern, int use_inclu
        
        intern->u.file.delimiter = ',';
        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);
 
diff --git a/ext/spl/tests/SplFileObject_fgetcsv_escape_default.phpt b/ext/spl/tests/SplFileObject_fgetcsv_escape_default.phpt
new file mode 100644 (file)
index 0000000..b3b6c7c
--- /dev/null
@@ -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"
+}