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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 23:01:28 2024 UTC