php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44442 parse_ini_file crashes on "(" or ")"
Submitted: 2008-03-15 10:33 UTC Modified: 2008-03-17 00:21 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: VJTD3 at VJTD3 dot com Assigned:
Status: Wont fix Package: Filesystem function related
PHP Version: 5.2.5 OS: any
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2008-03-15 10:33 UTC] VJTD3 at VJTD3 dot com
Description:
------------
if a ini file has a "(" or ")" in it the parse_ini_file function will end on the character before the "(" or ")". in some cases or remove the "(" and ")" or just dump everything between the "(" and ")".

In a nut shell it hates "(" and ")" for some reason.

Reproduce code:
---------------
sample "demo.ini" file:

[demo]
a=1
b=(
c=3

php -r "print_r(parse_ini_file('demo.ini', true));"


Expected result:
----------------
Array
(
    [demo] => Array
        (
            [a] => 1
            [b] => (
            [c] => 3
        )

)

Actual result:
--------------
Warning: Error parsing demo.ini on line 3
Array
(
    [demo] => Array
        (
            [a] => 1
            [b] =>
        )

)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-15 13:13 UTC] felipe@php.net
Says the documentation:

"Note: If a value in the ini file contains any non-alphanumeric characters it needs to be enclosed in double-quotes (")."

"... Characters {}|&~![()" must not be used anywhere in the key and have a special meaning in the value."


 [2008-03-15 13:49 UTC] VJTD3 at VJTD3 dot com
real files in real use in the real world don't go by that variation. anything right of the = is treated as plain text. there needs to be at bare minimum a flag to turn off the double quotes requirement. One example being the editing of third part programs where you can't just introduce double quotes and not have things break.
 [2008-03-17 00:21 UTC] jani@php.net
This has been like this for years. The ini file has certain syntax, live with it.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC