]> granicus.if.org Git - php/commitdiff
- Fixed bug #52138 (Constants are parsed into the ini file for section names)
authorFelipe Pena <felipe@php.net>
Thu, 24 Jun 2010 22:32:42 +0000 (22:32 +0000)
committerFelipe Pena <felipe@php.net>
Thu, 24 Jun 2010 22:32:42 +0000 (22:32 +0000)
NEWS
Zend/zend_ini_parser.y
ext/standard/tests/general_functions/bug52138.data [new file with mode: 0644]
ext/standard/tests/general_functions/bug52138.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 2296a8018643c1a43aa0eba8a55b4035994d18a7..478f398a27d0a951bcece228b9f53042ea6b422c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ PHP                                                                        NEWS
 - Fixed the mail.log ini setting when no filename was given. (Johannes)
 - Fixed bug #52162 (custom request header variables with numbers are removed). 
   (Sriram Natarajan)
+- Fixed bug #52138 (Constants are parsed into the ini file for section names).
+  (Felipe)
 - Fixed bug #52115 (mysqli_result::fetch_all returns null, not an empty array).
   (Andrey)
 
index c6534a6af2657ef8d6f926b3d97442629c6b0ee4..0e81b29f7e2d75c962afb05a68df2e86642f1b4c 100644 (file)
@@ -304,7 +304,7 @@ statement:
 ;
 
 section_string_or_value:
-               var_string_list                                 { $$ = $1; }
+               var_string_list_section                 { $$ = $1; }
        |       /* empty */                                             { zend_ini_init_string(&$$); }
 ;
 
@@ -326,6 +326,15 @@ encapsed_list:
        |       /* empty */                                             { zend_ini_init_string(&$$); }
 ;
 
+var_string_list_section:
+               cfg_var_ref                                             { $$ = $1; }
+       |       constant_literal                                { $$ = $1; }
+       |       '"' encapsed_list '"'                   { $$ = $2; }
+       |       var_string_list_section cfg_var_ref     { zend_ini_add_string(&$$, &$1, &$2); free(Z_STRVAL($2)); }
+       |       var_string_list_section constant_literal        { zend_ini_add_string(&$$, &$1, &$2); free(Z_STRVAL($2)); }
+       |       var_string_list_section '"' encapsed_list '"'  { zend_ini_add_string(&$$, &$1, &$3); free(Z_STRVAL($3)); }
+;
+
 var_string_list:
                cfg_var_ref                                             { $$ = $1; }
        |       constant_string                                 { $$ = $1; }
@@ -348,6 +357,14 @@ cfg_var_ref:
                TC_DOLLAR_CURLY TC_VARNAME '}'  { zend_ini_get_var(&$$, &$2 TSRMLS_CC); free(Z_STRVAL($2)); }
 ;
 
+constant_literal:
+               TC_CONSTANT                                             { $$ = $1; }
+       |       TC_RAW                                                  { $$ = $1; /*printf("TC_RAW: '%s'\n", Z_STRVAL($1));*/ }
+       |       TC_NUMBER                                               { $$ = $1; /*printf("TC_NUMBER: '%s'\n", Z_STRVAL($1));*/ }
+       |       TC_STRING                                               { $$ = $1; /*printf("TC_STRING: '%s'\n", Z_STRVAL($1));*/ }
+       |       TC_WHITESPACE                                   { $$ = $1; /*printf("TC_WHITESPACE: '%s'\n", Z_STRVAL($1));*/ }
+;
+
 constant_string:
                TC_CONSTANT                                             { zend_ini_get_constant(&$$, &$1 TSRMLS_CC); }
        |       TC_RAW                                                  { $$ = $1; /*printf("TC_RAW: '%s'\n", Z_STRVAL($1));*/ }
diff --git a/ext/standard/tests/general_functions/bug52138.data b/ext/standard/tests/general_functions/bug52138.data
new file mode 100644 (file)
index 0000000..4ce82e0
--- /dev/null
@@ -0,0 +1,11 @@
+[MYCONST]
+MYCONST = MYCONST
+
+[M_PI]
+FOO=M_PI " test"
+
+[foo::bar]
+A=1
+B=A "A" A
+
+[MYCONST M_PI]
diff --git a/ext/standard/tests/general_functions/bug52138.phpt b/ext/standard/tests/general_functions/bug52138.phpt
new file mode 100644 (file)
index 0000000..d4f3873
--- /dev/null
@@ -0,0 +1,37 @@
+--TEST--
+Bug #52138 (Constants are parsed into the ini file for section names)
+--FILE--
+<?php
+
+define('MYCONST', 1);
+define('A', 'B');
+
+$ini_file = dirname(__FILE__)."/bug52138.data";
+
+$ret = parse_ini_file($ini_file, true);
+var_dump($ret);
+
+?>
+--EXPECTF--
+array(4) {
+  ["MYCONST"]=>
+  array(1) {
+    ["MYCONST"]=>
+    string(1) "1"
+  }
+  ["M_PI"]=>
+  array(1) {
+    ["FOO"]=>
+    string(%d) "3.%d test"
+  }
+  ["foo::bar"]=>
+  array(2) {
+    ["A"]=>
+    string(1) "1"
+    ["B"]=>
+    string(3) "BAB"
+  }
+  ["MYCONST M_PI"]=>
+  array(0) {
+  }
+}