pajoye          Wed Nov 22 12:59:49 2006 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/standard/tests/file    bug39538.phpt 

  Modified files:              
    /php-src    NEWS 
    /php-src/ext/standard       file.c 
  Log:
  - MFH:  #39538, fgetcsv can't handle starting newlines and trailing odd
    number of backslashes (David Soria Parra, Pierre)
  
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.369&r2=1.2027.2.547.2.370&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.369 php-src/NEWS:1.2027.2.547.2.370
--- php-src/NEWS:1.2027.2.547.2.369     Wed Nov 22 10:42:41 2006
+++ php-src/NEWS        Wed Nov 22 12:59:48 2006
@@ -42,6 +42,8 @@
 - Fixed wrong signature initialization in imagepng (Takeshi Abe)
 - Added optimization for imageline with horizontal and vertial lines (Pierre)
 - Fixed bug #39576 (array_walk() doesn't separate userdata zval). (Tony)
+- Fixed bug #39538 (fgetcsv can't handle starting newlines and trailing odd
+  number of backslashes). (David Soria Parra, Pierre)
 - Fixed bug #39454 (Returning a SOAP array segfaults PHP). (Dmitry)
 - Fixed bug #39445 (Calling debug_backtrace() in the __toString() function
   produces a crash). (Dmitry)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.409.2.6.2.11&r2=1.409.2.6.2.12&diff_format=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.409.2.6.2.11 
php-src/ext/standard/file.c:1.409.2.6.2.12
--- php-src/ext/standard/file.c:1.409.2.6.2.11  Mon Nov 20 11:12:42 2006
+++ php-src/ext/standard/file.c Wed Nov 22 12:59:49 2006
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: file.c,v 1.409.2.6.2.11 2006/11/20 11:12:42 tony2001 Exp $ */
+/* $Id: file.c,v 1.409.2.6.2.12 2006/11/22 12:59:49 pajoye Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -2171,9 +2171,11 @@
                                                                size_t new_len;
                                                                char *new_temp;
 
-                                                               memcpy(tptr, 
hunk_begin, bptr - hunk_begin);
-                                                               tptr += (bptr - 
hunk_begin);
-                                                               hunk_begin = 
bptr;
+                                                               if (hunk_begin 
!= line_end) {
+                                                                       
memcpy(tptr, hunk_begin, bptr - hunk_begin);
+                                                                       tptr += 
(bptr - hunk_begin);
+                                                                       
hunk_begin = bptr;
+                                                               }
 
                                                                /* add the 
embedded line end to the field */
                                                                memcpy(tptr, 
line_end, line_end_len);

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/bug39538.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/file/bug39538.phpt
+++ php-src/ext/standard/tests/file/bug39538.phpt
--TEST--
bug 39538
--FILE--
<?php
$content = array("\"\nthis is an test\", \"next data\", 
\"p\narsed\"","\"\r\nthis is an test\", \"next data\", 
\"p\r\narsed\"","\"\n\rthis is an test\", \"next data\", \"p\n\rarsed\"");

$file = dirname(__FILE__) . "/bug39538.csv";
@unlink($file);
foreach ($content as $v) {
        file_put_contents($file, $v);
        print_r (fgetcsv(fopen($file, "r"), filesize($file)));
}
@unlink($file);
--EXPECT--
Array
(
    [0] => 
this is an test
    [1] => next data
    [2] => p
arsed
)
Array
(
    [0] => 
this is an test
    [1] => next data
    [2] => p
arsed
)
Array
(
    [0] => 
this is an test
    [1] => next data
    [2] => p
arsed
)



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to