Bug #55413 [Com]: str_getcsv doesnt remove escape characters

From: Date: Sun, 27 Nov 2011 13:58:50 +0000
Subject: Bug #55413 [Com]: str_getcsv doesnt remove escape characters
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-165522@lists.php.net to get a copy of this message
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

« previous php.bugs (#165522) next »