php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44609 parse_ini_file 'dollar'-sign problems
Submitted: 2008-04-02 12:32 UTC Modified: 2008-04-07 11:39 UTC
From: sander at procurios dot nl Assigned: scottmac (profile)
Status: Closed Package: Filesystem function related
PHP Version: 5.3CVS-2008-04-02 (snap) OS: Mac OS X
Private report: No CVE-ID: None
 [2008-04-02 12:32 UTC] sander at procurios dot nl
Description:
------------
Parse_ini_file gives a syntax error on 'dollar'-sign in INI-file.

Source: php5.3-200804021030.tar.gz (Built on: Apr 02, 2008 10:30 UTC)

Reproduce code:
---------------
<?php
// Set ini file location
$iniFileLocation = dirname(__FILE__) . '/test.ini';

// Build ini data
$iniData = '[database]
db_user = username
db_pass = "$@Yb^0P%$4$*"
db_name = database
db_host = localhost';

// Save ini data to file
file_put_contents($iniFileLocation, $iniData);

print_r(parse_ini_file($iniFileLocation));

Expected result:
----------------
Array
(
    [db_user] => username
    [db_pass] => $@Yb^0P%$4$*
    [db_name] => database
    [db_host] => localhost
)

Actual result:
--------------
Warning: syntax error, unexpected $end, expecting TC_DOLLAR_CURLY or TC_QUOTED_STRING or '"' in /data/www/test.ini on line 3 in /data/www/test.php on line 15
Array
(
    [db_user] => username
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-04-03 11:14 UTC] jani@php.net
Marcus, another "works before re2c" bug.
 [2008-04-03 13:29 UTC] scottmac@php.net
I did the ini changes and the syntax is the same as before apart from adding null to the disallowed characters.

LITERAL_DOLLAR ("$"([^a-zA-Z0-9{\000]|("\\"{ANY_CHAR})))

So $4 is what is invalid in the test.
 [2008-04-03 13:49 UTC] sander at procurios dot nl
I am not sure I understand what you are saying. Are you telling me that we are no longer allowed to use "$4" (or anything else that matches your pattern) in our INI files? That would be a major change, since the "Expected result" I posted was output that I got from executing the exact same code on PHP 5.2.5
 [2008-04-03 14:04 UTC] scottmac@php.net
The comment was towards Jani rather than yourself.

It will be changed, I'm just not sure what was originally intended.
 [2008-04-07 11:39 UTC] scottmac@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: Tue Apr 23 21:01:31 2024 UTC