Bug #53916 [Com]: parse_ini_file unable to handle strings with certain characters
| From: | zefredz@php.net | Date: | Thu, 07 Jun 2012 08:22:42 +0000 |
| Subject: | Bug #53916 [Com]: parse_ini_file unable to handle strings with certain characters | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-171093@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=53916&edit=1
ID: 53916
Comment by: zefredz@php.net
Reported by: thasypher at gmail dot com
Summary: parse_ini_file unable to handle strings with certain
characters
Status: Feedback
Type: Bug
Package: Filesystem function related
Operating System: Debian 5
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
I don't know if it will help to find the cause of this bug, but I found that
enclosing the string with quotes solves the problem :
ini file:
---------
[test]
some_thing = "R3iDn3!rj3j"
test file:
----------
<?php
print_r(parse_ini_file('bug.ini', true ));
result (as expected):
----------------------
Array ( [test] => Array ( [some_thing] => R3iDn3!rj3j ) )
Previous Comments:
------------------------------------------------------------------------
[2011-02-04 13:50:04] thasypher at gmail dot com
A sample INI could be:
----
[data]
test_case = 1
some_server = localhost
more_stuff = 8.8.8.8
[test]
somevalue = 1
password_server.domain.tld = h1b{k&Tx$jt2
----
In this case, it throws an "Error parsing <filename> on line 8.
Also with:
---
[test]
some_thing = R3iDn3!rj3j
---
it will fail.
So ISTM that special characters are causing issues in the parse_ini_file.
------------------------------------------------------------------------
[2011-02-04 10:46:39] aharvey@php.net
What version of PHP are you running? This seems to behave as expected
in PHP 5.3.5.
Could you also provide a (short) sample file.ini, please?
------------------------------------------------------------------------
[2011-02-03 09:00:14] thasypher at gmail dot com
Obviously the test script should not contain a comma next to the true value.
------------------------------------------------------------------------
[2011-02-03 08:56:52] thasypher at gmail dot com
Description:
------------
PHP seems to be unable to handle strings with certain signs (#$%) in an INI file parsed with
parse_ini_file.
It throws a warning while doing that.
Even though normally you would quote strings to overcome this issue, the ConfigParser implementation
of Python (for instance) does not do this.
Test script:
---------------
print_r(parse_ini_file('file.ini', true, ));
Expected result:
----------------
An ini file with certain characters will throw a warning and may not be parsed completely.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=53916&edit=1