php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32717 fgetcsv() against double quote
Submitted: 2005-04-15 13:56 UTC Modified: 2005-04-18 15:23 UTC
From: volf44 at yandex dot ru Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 4.3.11 OS: Linux, Windows 2k
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: volf44 at yandex dot ru
New email:
PHP Version: OS:

 

 [2005-04-15 13:56 UTC] volf44 at yandex dot ru
Description:
------------
fgetcsv() incorrect handles single double quote
in first position of the last record field.

Reproduce code:
---------------
file test.csv:
one|record with bad double quote|"4
two|record with good "|4
[EOF]

$fd = fopen( 'test.csv', 'rb' );
while( $rec = fgetcsv( $fd, 20480, '|' )){
    var_dump( $rec );
}


Expected result:
----------------
array(3) {
  [0]=>
  string(3) "one"
  [1]=>
  string(28) "record with bad double quote"
  [2]=>
  string(1) ""4"
}
array(3) {
  [0]=>
  string(3) "two"
  [1]=>
  string(18) "record with good ""
  [2]=>
  string(1) "4"
}

Actual result:
--------------
array(4) {
  [0]=>
  string(3) "one"
  [1]=>
  string(28) "record with bad double quote"
  [2]=>
  string(24) "4
two|record with good "
  [3]=>
  string(1) "4"
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-18 15:23 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is to be expected, quoted text can contain new lines, so "4 will continue until the closing quote is found. 
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 08 16:01:33 2025 UTC