diff options
author | Arnaud Le Blanc <lbarnaud@php.net> | 2008-11-02 23:36:10 +0000 |
---|---|---|
committer | Arnaud Le Blanc <lbarnaud@php.net> | 2008-11-02 23:36:10 +0000 |
commit | b3d0514b6f87af37a7750a0f4c95e4a12a8f7009 (patch) | |
tree | 09a0b7b6c3cc24f68067fcdcda1cd7bb8426cff5 | |
parent | 355f62c2645eb6cf8686cbda7e2bdc9600e2a83a (diff) | |
download | php-git-b3d0514b6f87af37a7750a0f4c95e4a12a8f7009.tar.gz |
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)
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | Zend/zend_ini_scanner.l | 7 | ||||
-rw-r--r-- | ext/standard/tests/general_functions/parse_ini_file.phpt | 22 |
3 files changed, 30 insertions, 0 deletions
@@ -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; } +<INITIAL>{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; +} + <ST_VALUE,ST_RAW>[^] { /* 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 |