Bug #76965 [NEW]: parse_ini_file, parse_ini_string INI_SCANNER_RAW and inline comments
From: mb at iname dot com
Operating system: CentOS
PHP version: 7.1.22
Package: *General Issues
Bug Type: Bug
Bug description:parse_ini_file, parse_ini_string INI_SCANNER_RAW and inline comments
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 bug report at https://bugs.php.net/bug.php?id=76965&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76965&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76965&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76965&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76965&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76965&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76965&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76965&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76965&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76965&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76965&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76965&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76965&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76965&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76965&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76965&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76965&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76965&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76965&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76965&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76965&r=mysqlcfg
Thread (5 messages)
- mb at iname dot com