svn: /php/php-src/ branches/PHP_5_3/ext/standard/file.c branches/PHP_5_3/ext/standard/tests/strings/bug55674.phpt branches/PHP_5_4/ext/standard/file.c
branches/PHP_5_4/ext/standard/tests/strings/bug55674.phpt trunk/ext/standard/file.c trunk/ext/standard/tests/strings/bug55674.phpt
| From: | Xinchen Hui | Date: | Tue, 13 Sep 2011 12:44:13 +0000 |
| Subject: | svn: /php/php-src/ branches/PHP_5_3/ext/standard/file.c branches/PHP_5_3/ext/standard/tests/strings/bug55674.phpt branches/PHP_5_4/ext/standard/file.c branches/PHP_5_4/ext/standard/tests/strings/bug55674.phpt trunk/ext/standard/file.c trunk/ext/standard/tests/strings/bug55674.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-66485@lists.php.net to get a copy of this message | ||
laruence Tue, 13 Sep 2011 12:44:13 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=316618
Log:
Fixed Bug #55674 (fgetcsv & str_getcsv skip empty fields in some tab-separated records) which
was introduced by r311543
Bug: https://bugs.php.net/55674 (Open) fgetcsv &
str_getcsv skip empty fields in some tab-separated records
Changed paths:
U php/php-src/branches/PHP_5_3/ext/standard/file.c
A php/php-src/branches/PHP_5_3/ext/standard/tests/strings/bug55674.phpt
U php/php-src/branches/PHP_5_4/ext/standard/file.c
A php/php-src/branches/PHP_5_4/ext/standard/tests/strings/bug55674.phpt
U php/php-src/trunk/ext/standard/file.c
A php/php-src/trunk/ext/standard/tests/strings/bug55674.phpt
Modified: php/php-src/branches/PHP_5_3/ext/standard/file.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/file.c 2011-09-13 12:42:17 UTC (rev 316617)
+++ php/php-src/branches/PHP_5_3/ext/standard/file.c 2011-09-13 12:44:13 UTC (rev 316618)
@@ -2199,7 +2199,7 @@
inc_len = (bptr < limit ? (*bptr == '\0' ? 1: php_mblen(bptr, limit - bptr)): 0);
if (inc_len == 1) {
char *tmp = bptr;
- while (isspace((int)*(unsigned char *)tmp)) {
+ while ((*tmp != delimiter) && isspace((int)*(unsigned char *)tmp)) {
tmp++;
}
if (*tmp == enclosure) {
Added: php/php-src/branches/PHP_5_3/ext/standard/tests/strings/bug55674.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/tests/strings/bug55674.phpt
(rev 0)
+++ php/php-src/branches/PHP_5_3/ext/standard/tests/strings/bug55674.phpt 2011-09-13 12:44:13 UTC
(rev 316618)
@@ -0,0 +1,50 @@
+--TEST--
+Bug #55674 (fgetcsv & str_getcsv skip empty fields in some tab-separated records)
+--FILE--
+<?php
+var_dump(str_getcsv("0\t\t\"2\"\n", "\t"));
+var_dump(str_getcsv("0\t \t'2'\n", "\t", "'"));
+var_dump(str_getcsv(",,,,"));
+var_dump(str_getcsv(" \t \t\t\t ", "\t"));
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ string(1) "0"
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(1) "2"
+}
+array(3) {
+ [0]=>
+ string(1) "0"
+ [1]=>
+ string(1) " "
+ [2]=>
+ string(1) "2"
+}
+array(5) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(0) ""
+}
+array(5) {
+ [0]=>
+ string(1) " "
+ [1]=>
+ string(2) " "
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(1) " "
+}
Modified: php/php-src/branches/PHP_5_4/ext/standard/file.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/standard/file.c 2011-09-13 12:42:17 UTC (rev 316617)
+++ php/php-src/branches/PHP_5_4/ext/standard/file.c 2011-09-13 12:44:13 UTC (rev 316618)
@@ -2051,7 +2051,7 @@
inc_len = (bptr < limit ? (*bptr == '\0' ? 1: php_mblen(bptr, limit - bptr)): 0);
if (inc_len == 1) {
char *tmp = bptr;
- while (isspace((int)*(unsigned char *)tmp)) {
+ while ((*tmp != delimiter) && isspace((int)*(unsigned char *)tmp)) {
tmp++;
}
if (*tmp == enclosure) {
Added: php/php-src/branches/PHP_5_4/ext/standard/tests/strings/bug55674.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/ext/standard/tests/strings/bug55674.phpt
(rev 0)
+++ php/php-src/branches/PHP_5_4/ext/standard/tests/strings/bug55674.phpt 2011-09-13 12:44:13 UTC
(rev 316618)
@@ -0,0 +1,50 @@
+--TEST--
+Bug #55674 (fgetcsv & str_getcsv skip empty fields in some tab-separated records)
+--FILE--
+<?php
+var_dump(str_getcsv("0\t\t\"2\"\n", "\t"));
+var_dump(str_getcsv("0\t \t'2'\n", "\t", "'"));
+var_dump(str_getcsv(",,,,"));
+var_dump(str_getcsv(" \t \t\t\t ", "\t"));
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ string(1) "0"
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(1) "2"
+}
+array(3) {
+ [0]=>
+ string(1) "0"
+ [1]=>
+ string(1) " "
+ [2]=>
+ string(1) "2"
+}
+array(5) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(0) ""
+}
+array(5) {
+ [0]=>
+ string(1) " "
+ [1]=>
+ string(2) " "
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(1) " "
+}
Modified: php/php-src/trunk/ext/standard/file.c
===================================================================
--- php/php-src/trunk/ext/standard/file.c 2011-09-13 12:42:17 UTC (rev 316617)
+++ php/php-src/trunk/ext/standard/file.c 2011-09-13 12:44:13 UTC (rev 316618)
@@ -2051,7 +2051,7 @@
inc_len = (bptr < limit ? (*bptr == '\0' ? 1: php_mblen(bptr, limit - bptr)): 0);
if (inc_len == 1) {
char *tmp = bptr;
- while (isspace((int)*(unsigned char *)tmp)) {
+ while ((*tmp != delimiter) && isspace((int)*(unsigned char *)tmp)) {
tmp++;
}
if (*tmp == enclosure) {
Added: php/php-src/trunk/ext/standard/tests/strings/bug55674.phpt
===================================================================
--- php/php-src/trunk/ext/standard/tests/strings/bug55674.phpt (rev 0)
+++ php/php-src/trunk/ext/standard/tests/strings/bug55674.phpt 2011-09-13 12:44:13 UTC (rev 316618)
@@ -0,0 +1,50 @@
+--TEST--
+Bug #55674 (fgetcsv & str_getcsv skip empty fields in some tab-separated records)
+--FILE--
+<?php
+var_dump(str_getcsv("0\t\t\"2\"\n", "\t"));
+var_dump(str_getcsv("0\t \t'2'\n", "\t", "'"));
+var_dump(str_getcsv(",,,,"));
+var_dump(str_getcsv(" \t \t\t\t ", "\t"));
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ string(1) "0"
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(1) "2"
+}
+array(3) {
+ [0]=>
+ string(1) "0"
+ [1]=>
+ string(1) " "
+ [2]=>
+ string(1) "2"
+}
+array(5) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(0) ""
+}
+array(5) {
+ [0]=>
+ string(1) " "
+ [1]=>
+ string(2) " "
+ [2]=>
+ string(0) ""
+ [3]=>
+ string(0) ""
+ [4]=>
+ string(1) " "
+}