From 84dc845ff81d689d22c8f6e9c647b3bcb9748e35 Mon Sep 17 00:00:00 2001 From: Adam Harvey Date: Tue, 9 Nov 2010 14:53:23 +0000 Subject: [PATCH] Fix bug #53279 (SplFileObject doesn't initialise default CSV escape character). --- NEWS | 2 ++ ext/spl/spl_directory.c | 1 + .../SplFileObject_fgetcsv_escape_default.phpt | 24 +++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 ext/spl/tests/SplFileObject_fgetcsv_escape_default.phpt diff --git a/NEWS b/NEWS index 7f8fb0a9ab..be5c46ce4d 100644 --- 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) diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 98e810ab04..f4c61fd5c1 100755 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -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 index 0000000000..b3b6c7c609 --- /dev/null +++ b/ext/spl/tests/SplFileObject_fgetcsv_escape_default.phpt @@ -0,0 +1,24 @@ +--TEST-- +SplFileObject::fgetcsv with default escape character +--FILE-- +fgetcsv()); +?> +--CLEAN-- + +--EXPECTF-- +array(3) { + [0]=> + string(4) "aa\"" + [1]=> + string(2) "bb" + [2]=> + string(3) "\"c" +} -- 2.40.0