Bug #66588 [NEW]: SplFileObject::fgetcsv incorrectly returns a row on premature EOF
From: jameshfisher at gmail dot com
Operating system: Ubuntu 12.04.4 LTS
PHP version: 5.5.8
Package: SPL related
Bug Type: Bug
Bug description:SplFileObject::fgetcsv incorrectly returns a row on premature EOF
Description:
------------
---
From manual page: http://www.php.net/splfileobject.fgetcsv
---
Test script:
---------------
Assume the file invalid.csv contains:
blah,"blah
Then run the script below:
#!/usr/bin/env php5
<?php
$s = new \SplFileObject('invalid.csv');
$r = NULL;
while (!$s->eof())
{
var_dump($s->fgetcsv(',','"'));
}
Expected result:
----------------
An error, signalled by FALSE, as described in the documentation for the
method:
$ ./test.php
bool(false)
Actual result:
--------------
The cell in the file that does not have a closing quotation mark is
treated as if EOF is the closing quotation mark. This is not compliant
with the RFC: https://tools.ietf.org/html/rfc4180
$ ./test.php
array(2) {
[0]=>
string(4) "blah"
[1]=>
string(5) "blah
"
}
--
Edit bug report at https://bugs.php.net/bug.php?id=66588&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66588&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66588&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66588&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66588&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66588&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66588&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66588&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66588&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66588&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66588&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66588&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66588&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66588&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66588&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66588&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66588&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66588&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66588&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66588&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66588&r=mysqlcfg
Thread (6 messages)
- jameshfisher at gmail dot com