From: Arnaud Le Blanc Date: Sun, 17 Aug 2008 21:51:36 +0000 (+0000) Subject: Allow underscore at start of labels as underscore has no meaning here X-Git-Tag: BEFORE_HEAD_NS_CHANGE~679 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c9789b9eb3d70c5b0c007b4e5f5b11a35ab110b3;p=php Allow underscore at start of labels as underscore has no meaning here (fixes #44842) --- diff --git a/Zend/zend_ini_scanner.l b/Zend/zend_ini_scanner.l index f7cb2903d2..b100076862 100644 --- a/Zend/zend_ini_scanner.l +++ b/Zend/zend_ini_scanner.l @@ -312,7 +312,7 @@ NEWLINE ("\r"|"\n"|"\r\n") TABS_AND_SPACES [ \t] WHITESPACE [ \t]+ CONSTANT [a-zA-Z][a-zA-Z0-9_]* -LABEL [a-zA-Z0-9][a-zA-Z0-9._-]* +LABEL [a-zA-Z0-9_][a-zA-Z0-9._-]* TOKENS [:,.\[\]"'()|^&+-/*=%$!~<>?@{}] OPERATORS [&|~()!] DOLLAR_CURLY "${" diff --git a/ext/standard/tests/general_functions/parse_ini_file.phpt b/ext/standard/tests/general_functions/parse_ini_file.phpt index f08717f934..e24c45444c 100644 --- a/ext/standard/tests/general_functions/parse_ini_file.phpt +++ b/ext/standard/tests/general_functions/parse_ini_file.phpt @@ -94,6 +94,15 @@ $ini = "[section1]\nname = value"; file_put_contents($filename, $ini); var_dump(parse_ini_file($filename, true)); +/* #44842, labels starting with underscore */ +$ini = <<<'INI' +foo=bar1 +_foo=bar2 +foo_=bar3 +INI; +file_put_contents($filename, $ini); +var_dump(parse_ini_file($filename, true)); + @unlink($filename); echo "Done\n"; ?> @@ -182,4 +191,12 @@ array(1) { unicode(5) "value" } } +array(3) { + [u"foo"]=> + unicode(4) "bar1" + [u"_foo"]=> + unicode(4) "bar2" + [u"foo_"]=> + unicode(4) "bar3" +} Done