From:
Operating system:
PHP version: 5.3.6
Package: Unknown/Other Function
Bug Type: Bug
Bug description:str_getcsv parses lines incorrectly
Description:
------------
Putting a space around the separator *and* using quotes around fields adds
spaces to the field. The following line:
"123" , "456"
should produce:
"123" and "456"
but it makes:
"123 " and " 456".
In the RFC4180 the specification suggests that if the field contains
quotes,
only the text inside quotes is the content of the field. Here is the formal
gramma:
record = field *(COMMA field)
field = (escaped / non-escaped)
escaped = DQUOTE *(TEXTDATA / COMMA / CR / LF / 2DQUOTE) DQUOTE
non-escaped = *TEXTDATA
Thus spaces should appear in field only if the field is not quoted.
Test script:
---------------
print_r(str_getcsv('"123" , "456" ', ',', '"'))
Expected result:
----------------
array(
0 => "123",
1 => "456",
)
Actual result:
--------------
array(
0 => "123 ",
1 => "456 ",
)
--
Edit bug report at https://bugs.php.net/bug.php?id=55200&edit=1
--
Try a snapshot (PHP 5.2):
https://bugs.php.net/fix.php?id=55200&r=trysnapshot52
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=55200&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=55200&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=55200&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=55200&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=55200&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=55200&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=55200&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=55200&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=55200&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=55200&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=55200&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=55200&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=55200&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=55200&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=55200&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=55200&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=55200&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=55200&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=55200&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=55200&r=mysqlcfg
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=55200&r=trysnapshot54