Bug #76965 [Ver->Csd]: INI_SCANNER_RAW doesn't strip trailing whitespace
Edit report at https://bugs.php.net/bug.php?id=76965&edit=1
ID: 76965
Updated by: pierrick@php.net
Reported by: mb at iname dot com
Summary: INI_SCANNER_RAW doesn't strip trailing whitespace
-Status: Verified
+Status: Closed
Type: Bug
Package: *General Issues
Operating System: CentOS
PHP Version: 7.1.22
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of pierrick
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f42d7bddc0479651ecf7f9cdf375bba74b609bea
Log: Fixed bug #76965 INI_SCANNER_RAW doesn't strip trailing whitespace
Previous Comments:
------------------------------------------------------------------------
[2018-10-08 13:39:32] cmb@php.net
The former PR has been superseeded by
<https://github.com/php/php-src/pull/3587>.
------------------------------------------------------------------------
[2018-10-03 11:15:43] cmb@php.net
This is not particularly related to trailing line comments, but
rather to trailing whitespace generally.
<https://github.com/php/php-src/pull/3572> is
supposed to fix the
issue.
------------------------------------------------------------------------
[2018-10-03 09:34:02] cmb@php.net
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.
------------------------------------------------------------------------
[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)