Bug #76965 [Opn->Ver]: parse_ini_file, parse_ini_string INI_SCANNER_RAW and inline comments
Edit report at https://bugs.php.net/bug.php?id=76965&edit=1
ID: 76965
Updated by: cmb@php.net
Reported by: mb at iname dot com
Summary: parse_ini_file, parse_ini_string INI_SCANNER_RAW and
inline comments
-Status: Open
+Status: Verified
Type: Bug
Package: *General Issues
Operating System: CentOS
PHP Version: 7.1.22
Block user comment: N
Private report: N
New Comment:
Confirmed: <https://3v4l.org/7FQHA>.
For consistency with INI_SCANNER_NORMAL and INI_SCANNER_TYPED we
should support inline comments also for INI_SCANNER_RAW.
Previous Comments:
------------------------------------------------------------------------
[2018-10-03 02:15:03] mb at iname dot com
Description:
------------
When a line contains a comment after the value, parse_ini_string and parse_ini_file in
INI_SCANNER_RAW mode pass double quotes and optionally spaces into the value, but strip the
semicolon and comment. Logically, if inline comments (comments not taking the whole line) are
supported, they should be stripped before parsing the values. If such comments are not supported,
they should be included into the value. If this is normal and expected behaviour, it should be
documented.
Test script:
---------------
<?php
$ini = <<<END
[section]
1="Hello"
2="Hello" ; comment
END;
var_dump(parse_ini_string($ini,true,INI_SCANNER_RAW));
$tmp = tempnam('.','tmp');
file_put_contents($tmp,$ini);
var_dump(parse_ini_file($tmp,true,INI_SCANNER_RAW));
unlink($tmp);
Expected result:
----------------
Expecting either to elements 1 and 2 with the same value, or element 2 containing the inline comment
if inline comments are not supported.
Actual result:
--------------
array(1) {
["section"]=>
array(2) {
[1]=>
string(5) "Hello"
[2]=>
string(8) ""Hello" "
}
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76965&edit=1
Thread (5 messages)