From: Arnaud Le Blanc Date: Sun, 2 Nov 2008 23:36:10 +0000 (+0000) Subject: Fixed bug #44575 (parse_ini_file comment # line problems) X-Git-Tag: BEFORE_NS_RULES_CHANGE~123 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b3d0514b6f87af37a7750a0f4c95e4a12a8f7009;p=php Fixed bug #44575 (parse_ini_file comment # line problems) [DOC] parse_ini_file(): comments starting with # are deprecated in PHP 5.3 (comments starting with ; should be used instead) --- diff --git a/NEWS b/NEWS index bc30206e8b..fbd8c05dbc 100644 --- a/NEWS +++ b/NEWS @@ -59,6 +59,7 @@ PHP NEWS - Fixed bug #45392 (ob_start()/ob_end_clean() and memory_limit). (Ilia) - Fixed bug #45382 (timeout bug in stream_socket_enable_crypto). (vnegrier at optilian dot com, Ilia) +- Fixed bug #44575 (parse_ini_file comment # line problems). (Arnaud) - Fixed bug #44135 (PDO MySQL does not support CLIENT_FOUND_ROWS). (Johannes, chx1975 at gmail dot com) diff --git a/Zend/zend_ini_scanner.l b/Zend/zend_ini_scanner.l index d901522ca6..22228837c9 100644 --- a/Zend/zend_ini_scanner.l +++ b/Zend/zend_ini_scanner.l @@ -480,6 +480,13 @@ DOUBLE_QUOTES_CHARS ([^$"\\]|("\\"[^"])|{LITERAL_DOLLAR}|"\\"["][^\r\n]) return END_OF_LINE; } +{TABS_AND_SPACES}*[#][^\r\n]*{NEWLINE} { /* #Comment */ + zend_error(E_DEPRECATED, "Comments starting with '#' are deprecated in %s on line %d", ini_filename, SCNG(lineno)); + BEGIN(INITIAL); + SCNG(lineno)++; + return END_OF_LINE; +} + [^] { /* End of option value (if EOF is reached before EOL */ BEGIN(INITIAL); return END_OF_LINE; diff --git a/ext/standard/tests/general_functions/parse_ini_file.phpt b/ext/standard/tests/general_functions/parse_ini_file.phpt index 65a29e0022..8523c83cf0 100644 --- a/ext/standard/tests/general_functions/parse_ini_file.phpt +++ b/ext/standard/tests/general_functions/parse_ini_file.phpt @@ -105,6 +105,18 @@ INI; file_put_contents($filename, $ini); var_dump(parse_ini_file($filename, true)); +/* #44575, comments starting with '#' */ +$ini = <<<'INI' +foo=bar1 +; comment +_foo=bar2 +# comment +foo_=bar3 +INI; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename, true)); + + @unlink($filename); echo "Done\n"; ?> @@ -193,4 +205,14 @@ array(3) { ["foo_"]=> string(4) "bar3" } + +Deprecated: Comments starting with '#' are deprecated in %s +array(3) { + ["foo"]=> + string(4) "bar1" + ["_foo"]=> + string(4) "bar2" + ["foo_"]=> + string(4) "bar3" +} Done