Edit report at https://bugs.php.net/bug.php?id=55413&edit=1

 ID:                 55413
 Comment by:         xoneca at gmail dot com
 Reported by:        mathielen at gmail dot com
 Summary:            str_getcsv doesnt remove escape characters
 Status:             Open
 Type:               Bug
 Package:            Strings related
 Operating System:   ubuntu 11.04
 PHP Version:        5.3.6
 Block user comment: N
 Private report:     N

 New Comment:

The bug can be reproduced with any escape character but quote char.

Test script:
---------------
$line = '"A";"Some ""Stuff""";"C"';
$tokens = str_getcsv( $line, ';', '"', '"' );
print_r( $tokens );

Actual and Expected Result:
---------------
Array
(
    [0] => A
    [1] => Some "Stuff"
    [2] => C
)


Previous Comments:
------------------------------------------------------------------------
[2011-08-12 13:30:02] mathielen at gmail dot com

Description:
------------
Escape-characters should only escape the next character if it is the 
delimiter-character. The Escape character itself should then be removed from 
the result.

Test script:
---------------
$line = '"A";"Some \"Stuff\"";"C"';
$token = str_getcsv($line, ';', '"', '\\');
print_r($token);

Expected result:
----------------
Array
(
    [0] => A
    [1] => Some "Stuff"
    [2] => C
)


Actual result:
--------------
Array
(
    [0] => A
    [1] => Some \"Stuff\"
    [2] => C
)


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=55413&edit=1

Reply via email to