php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44574 parse_ini_file eof problem
Submitted: 2008-03-31 09:24 UTC Modified: 2008-08-17 21:37 UTC
From: letssurf at gmail dot com Assigned: helly (profile)
Status: Closed Package: Filesystem function related
PHP Version: 5.3CVS-2008-03-31 (snap) OS: Linux 2.6.9-34
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: letssurf at gmail dot com
New email:
PHP Version: OS:

 

 [2008-03-31 09:24 UTC] letssurf at gmail dot com
Description:
------------
parse_ini_file doesn't see the EOF as a delimiter for ini entries.

Reproduce code:
---------------
-- file: config.ini --
[section1]
name = value <<< EOF here, no new line

-- file: test.php --
<?php
$ini = parse_ini_file('config.ini', true);
print_r($ini);


Expected result:
----------------
Array ( [section1] => Array ( [name] => value ) )

Actual result:
--------------
Warning: syntax error, unexpected $end in eof.ini on line 2 in test.php on line 2
Array ( [section1] => Array ( ) )

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-04-02 10:21 UTC] letssurf at gmail dot com
Retested with builds

Win32 build Apr 2 2008 04:17:01, same problem
Linux built php5.3-200804020830, same problem

-- file: test1.php --
<?php
$filename = dirname(__FILE__).'/test.ini';

$data = "[section1]\nname = value";
file_put_contents($filename, $data);

$ini = parse_ini_file($filename, true);
print_r($ini);


-- file: test2.php --
<?php
$filename = dirname(__FILE__).'/test.ini';

$data = "[section1]\nname = value\n";
file_put_contents($filename, $data);

$ini = parse_ini_file($filename, true);
print_r($ini);

--

test1.php doesn't work gives an error Warning: syntax error, unexpected $end in test.ini on line 2
 in test1.php on line 7

test2.php works no problem
 [2008-04-02 10:25 UTC] jani@php.net
Apparently the transition from flex -> re2c caused this since I can't reproduce this with php build made prior that. Marcus..?
 [2008-04-08 12:40 UTC] jani@php.net
Added this missing case to ext/standard/tests/general_funcs/parse_ini_file.phpt.
 [2008-08-17 21:37 UTC] lbarnaud@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Oct 05 22:01:26 2024 UTC