]> granicus.if.org Git - php/commitdiff
MFH: Allow underscore at start of labels as underscore has no meaning here
authorArnaud Le Blanc <lbarnaud@php.net>
Sun, 17 Aug 2008 21:55:26 +0000 (21:55 +0000)
committerArnaud Le Blanc <lbarnaud@php.net>
Sun, 17 Aug 2008 21:55:26 +0000 (21:55 +0000)
(fixes #44842)

NEWS
Zend/zend_ini_scanner.l
ext/standard/tests/general_functions/parse_ini_file.phpt

diff --git a/NEWS b/NEWS
index 29cc73c3b151f310b14927ed3cc706bebddd3e63..4bac30841227706943e4056854abc8c89030978d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -38,6 +38,8 @@ PHP                                                                        NEWS
   newline). (Arnaud)
 - Fixed bug #45044 (relative paths not resolved correctly). (Dmitry)
 - Fixed bug #44925 (preg_grep() modifies input array). (Nuno)
+- Fixed bug #44842 (parse_ini_file keys that start/end with underscore). 
+  (Arnaud)
 - Fixed bug #44100 (Inconsistent handling of static array declarations with
   duplicate keys). (Dmitry)
 - Fixed bug #43817 (opendir() fails on Windows directories with parent
index 901b52681a2c1578da5fccdd77a4072167e300e5..742bbe2b2439442342d23e7c015672fbb1f356cc 100644 (file)
@@ -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 "${"
index 236845108041765b5df4df6209fd18fe7147b915..e7b9e898c20761554676026e03232f0f074b0a2e 100644 (file)
@@ -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) {
     string(5) "value"
   }
 }
+array(3) {
+  ["foo"]=>
+  string(4) "bar1"
+  ["_foo"]=>
+  string(4) "bar2"
+  ["foo_"]=>
+  string(4) "bar3"
+}
 Done