Skip to content

Commit

Permalink
Merge branch 'PHP-5.3' into PHP-5.4
Browse files Browse the repository at this point in the history
* PHP-5.3:
  Revert "Update fputcsv() to escape all characters equally."
  • Loading branch information
LawnGnome committed Jan 15, 2013
2 parents 374ebc8 + c077074 commit b1bf524
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 29 deletions.
2 changes: 0 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ PHP NEWS
(Laruence)
. Fixed bug #63899 (Use after scope error in zend_compile). (Laruence)
. Fixed bug #63882 (zend_std_compare_objects crash on recursion). (Dmitry)
. Fixed bug #43225 (fputcsv incorrectly handles cells ending in \ followed
by "). (Adam)
. Support BITMAPV5HEADER in getimagesize(). (AsamK, Lars)

- Date:
Expand Down
8 changes: 6 additions & 2 deletions ext/standard/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1871,16 +1871,20 @@ PHPAPI int php_fputcsv(php_stream *stream, zval *fields, char delimiter, char en
FPUTCSV_FLD_CHK('\n') ||
FPUTCSV_FLD_CHK('\r') ||
FPUTCSV_FLD_CHK('\t') ||
FPUTCSV_FLD_CHK('\\') ||
FPUTCSV_FLD_CHK(' ')
) {
char *ch = Z_STRVAL(field);
char *end = ch + Z_STRLEN(field);
int escaped = 0;

smart_str_appendc(&csvline, enclosure);
while (ch < end) {
if (*ch == enclosure) {
if (*ch == escape_char) {
escaped = 1;
} else if (!escaped && *ch == enclosure) {
smart_str_appendc(&csvline, enclosure);
} else {
escaped = 0;
}
smart_str_appendc(&csvline, *ch);
ch++;
Expand Down
10 changes: 5 additions & 5 deletions ext/standard/tests/file/fputcsv.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ echo '$list = ';var_export($res);echo ";\n";

$fp = fopen($file, "r");
$res = array();
while($l=fgetcsv($fp, 0, ',', '"', '"'))
while($l=fgetcsv($fp))
{
$res[] = join(',',$l);
}
Expand Down Expand Up @@ -75,10 +75,10 @@ $list = array (
13 => 'aaa,"""bbb """',
14 => '"aaa""aaa""","""bbb""bbb"',
15 => '"aaa""aaa""""""",bbb',
16 => 'aaa,"""\\""bbb",ccc',
17 => '"aaa""\\""a""","""bbb"""',
18 => '"""\\""""","""aaa"""',
19 => '"""\\""""""",aaa',
16 => 'aaa,"""\\"bbb",ccc',
17 => '"aaa""\\"a""","""bbb"""',
18 => '"""\\"""","""aaa"""',
19 => '"""\\"""""",aaa',
);
$list = array (
0 => 'aaa,bbb',
Expand Down
20 changes: 0 additions & 20 deletions ext/standard/tests/file/fputcsv_bug43225.phpt

This file was deleted.

0 comments on commit b1bf524

Please sign in to comment.