Bug #76965 [Ver]: INI_SCANNER_RAW doesn't strip trailing whitespace

From: Date: Mon, 08 Oct 2018 13:39:32 +0000
Subject: Bug #76965 [Ver]: INI_SCANNER_RAW doesn't strip trailing whitespace
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217472@lists.php.net to get a copy of this message
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: INI_SCANNER_RAW doesn't strip trailing whitespace Status: Verified Type: Bug Package: *General Issues Operating System: CentOS PHP Version: 7.1.22 Block user comment: N Private report: N New Comment: The former PR has been superseeded by <https://github.com/php/php-src/pull/3587>. Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#217472) next »