From: Ilia Alshanetsky Date: Mon, 15 Dec 2003 18:53:26 +0000 (+0000) Subject: Fixed bug #26634 & added test case. X-Git-Tag: php-4.3.5RC1~57 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a4935ca741c79fdda5340b2fd382d1093541152b;p=php Fixed bug #26634 & added test case. --- diff --git a/ext/standard/file.c b/ext/standard/file.c index 4ee1e5b84b..e1f88e675b 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -2266,16 +2266,17 @@ PHP_FUNCTION(fgetcsv) array_init(return_value); -#define CSV_ADD_ENTRY(s, es, st) { \ - int len = es - st; \ - if (len) { \ - while (isspace((int)*(unsigned char *)s)) { \ - s++; \ - len--; \ +#define CSV_ADD_ENTRY(os, es, st) { \ + int tmp_sl = es - st; \ + char *tmp_s=os; \ + if (tmp_sl) { \ + while (isspace((int)*(unsigned char *)tmp_s)) { \ + tmp_s++; \ + tmp_sl--; \ } \ } \ - if (len) { \ - add_next_index_stringl(return_value, s, len, 1); \ + if (tmp_sl) { \ + add_next_index_stringl(return_value, tmp_s, tmp_sl, 1); \ } else { \ add_next_index_string(return_value, "", 1); \ } \ diff --git a/ext/standard/tests/file/bug26634.phpt b/ext/standard/tests/file/bug26634.phpt new file mode 100644 index 0000000000..b9a46dbea4 --- /dev/null +++ b/ext/standard/tests/file/bug26634.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug #26634 (fgetcsv() incorrect handling of multiline entries with backslashes) +--FILE-- + +--EXPECT-- +Array +( + [0] => + [1] => + [2] => 971221 + [3] => 1 +) +Array +( + [0] => + [1] => + [2] => 950707 + [3] => \\ +\\ +) +Array +( + [0] => + [1] => + [2] => 999637 + [3] => ERYC 250 +) diff --git a/ext/standard/tests/file/test4.csv b/ext/standard/tests/file/test4.csv new file mode 100644 index 0000000000..8b71b8d0d0 --- /dev/null +++ b/ext/standard/tests/file/test4.csv @@ -0,0 +1,4 @@ +" " "" "971221" "1" +" " "" "950707" "\\ +\\" +" " "" "999637" "ERYC 250"