From: Xinchen Hui Date: Tue, 13 Sep 2011 12:44:13 +0000 (+0000) Subject: Fixed Bug #55674 (fgetcsv & str_getcsv skip empty fields in some tab-separated record... X-Git-Tag: php-5.5.0alpha1~1157 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=84c94e29c9bb7c3b27d7b4fb41c599fb774f4faf;p=php Fixed Bug #55674 (fgetcsv & str_getcsv skip empty fields in some tab-separated records) which was introduced by r311543 --- diff --git a/ext/standard/file.c b/ext/standard/file.c index 3ef8980f24..4240e74e81 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -2051,7 +2051,7 @@ PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, char 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) { diff --git a/ext/standard/tests/strings/bug55674.phpt b/ext/standard/tests/strings/bug55674.phpt new file mode 100644 index 0000000000..72ece642a7 --- /dev/null +++ b/ext/standard/tests/strings/bug55674.phpt @@ -0,0 +1,50 @@ +--TEST-- +Bug #55674 (fgetcsv & str_getcsv skip empty fields in some tab-separated records) +--FILE-- + +--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) " " +}