php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68461 parse_ini_file not parsing conf file if it has line like "on="
Submitted: 2014-11-20 12:42 UTC Modified: 2021-03-03 13:57 UTC
From: sandeep dot singh dot bisht at gmail dot com Assigned:
Status: Re-Opened Package: Filesystem function related
PHP Version: 5.5.19 OS: Ubuntu
Private report: No CVE-ID: None
 [2014-11-20 12:42 UTC] sandeep dot singh dot bisht at gmail dot com
Description:
------------
If conf file have something like 
on=

Then it throws warning

php: PHP Warning:  syntax error, unexpected BOOL_TRUE in test.conf on line 4#012 in /tmp/test.php on line 2

Test script:
---------------
$ cat test.conf
[data]
test=test
abc=abc
on=test


$ cat test.php
<?php
$conf=parse_ini_file("test.conf",true);
print_r($conf);
?>

$php test.php

Not printing anything.But getting this warning

php: PHP Warning:  syntax error, unexpected BOOL_TRUE in test.conf on line 4#012 in /tmp/test.php on line 2


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-11-20 17:16 UTC] requinix@php.net
See also bug #68347, though I don't think it can be reasonably argued that this version is not a bug either.
 [2018-08-20 21:56 UTC] cmb@php.net
-Package: Filter related +Package: Filesystem function related
 [2020-10-07 16:03 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2020-10-07 16:03 UTC] cmb@php.net
Well, we can't fix that without breaking valid code, and the
"feature" behaves as advertized anyway[1].  So I'm going to close
this as not a bug.

[1] <https://www.php.net/manual/en/function.parse-ini-file.php>
 [2021-03-03 13:40 UTC] krzysiek at example dot com
This is also how parser is behaving with INI_SCANNER_RAW which is at least unexpected. In that mode I feel everything should be parsed as string. And also this probably wouldn't be a breaking change since with "on" in key, function will fail all together. Unless obviously someone is relaying on having error.
 [2021-03-03 13:57 UTC] cmb@php.net
-Status: Not a bug +Status: Re-Opened -Assigned To: cmb +Assigned To:
 [2021-03-03 13:57 UTC] cmb@php.net
Ugh, I thought that wouldn't affect INI_SCANNER_RAW, but obviously
it does, and it is even documented.  And yes, you're right, fixing
this would not really cause a BC break.
 [2021-03-03 17:26 UTC] krzysiek at example dot com
Example with INI_SCANNER_RAW: https://3v4l.org/OmjJD
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 12 14:01:28 2024 UTC