]> granicus.if.org Git - php/commitdiff
MFH: Fixed bug #26176 (Fixed handling of numeric keys in INI files).
authorIlia Alshanetsky <iliaa@php.net>
Mon, 10 Nov 2003 04:12:50 +0000 (04:12 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 10 Nov 2003 04:12:50 +0000 (04:12 +0000)
NEWS
ext/standard/basic_functions.c

diff --git a/NEWS b/NEWS
index 6a40a36dda46adb1cbabd5b09e79e24bf6750101..af5d7f4556327dd9e58c64cd0b84b288a0251027 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ PHP 4                                                                      NEWS
 ?? ??? 2003, Version 4.3.5
 - Fixed header handler in NSAPI SAPI module (header->replace was ignored,
   send_default_content_type now sends value from php.ini). (Uwe Schindler)
+- Fixed bug #26176 (Fixed handling of numeric keys in INI files). (Ilia)
 - Fixed bug #26148 (Print the notice before modifying variable on type
   mismatch). (morten-bugs dot php dot net at afdelingp dot dk, Ilia)
 - Fixed bug #26128 (mbstring prints out wrong information on phpinfo()).
index 6725f8fc1afd82c6e3523f19073d8aa8eda08cb1..2bcd5e6c427085c30ea78f1629f8ea60aa173177 100644 (file)
@@ -2789,7 +2789,12 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, int callback_type,
                        *element = *arg2;
                        zval_copy_ctor(element);
                        INIT_PZVAL(element);
-                       zend_hash_update(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &element, sizeof(zval *), NULL);
+                       if (is_numeric_string(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1), NULL, NULL, 0) != IS_LONG) { 
+                               zend_hash_update(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, &element, sizeof(zval *), NULL);
+                       } else {
+                               ulong key = (ulong) zend_atoi(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1));
+                               zend_hash_index_update(Z_ARRVAL_P(arr), key, &element, sizeof(zval *), NULL);
+                       }
                        break;
 
                case ZEND_INI_PARSER_SECTION:
@@ -2822,20 +2827,27 @@ static void php_ini_parser_cb_with_sections(zval *arg1, zval *arg2, int callback
                        *element = *arg2;
                        zval_copy_ctor(element);
                        INIT_PZVAL(element);
-                       zend_hash_update(Z_ARRVAL_P(active_arr), Z_STRVAL_P(arg1),
+                       if (is_numeric_string(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1), NULL, NULL, 0) != IS_LONG) {
+                               zend_hash_update(Z_ARRVAL_P(active_arr), Z_STRVAL_P(arg1),
                                                         Z_STRLEN_P(arg1)+1, &element,
                                                         sizeof(zval *), NULL);
+                       } else {
+                               ulong key = (ulong) zend_atoi(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1));
+                               zend_hash_index_update(Z_ARRVAL_P(active_arr), key, &element, sizeof(zval *), NULL);
+                       }
                }
                break;
 
                case ZEND_INI_PARSER_SECTION:
                        MAKE_STD_ZVAL(BG(active_ini_file_section));
                        array_init(BG(active_ini_file_section));
-                       zend_hash_update(       Z_ARRVAL_P(arr),
-                                                               Z_STRVAL_P(arg1),
-                                                               Z_STRLEN_P(arg1)+1,
-                                                               &BG(active_ini_file_section),
-                                                               sizeof(zval *), NULL);
+                       if (is_numeric_string(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1), NULL, NULL, 0) != IS_LONG) {
+                               zend_hash_update(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1,
+                                                       &BG(active_ini_file_section), sizeof(zval *), NULL);
+                       } else {
+                               ulong key = (ulong) zend_atoi(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1));
+                               zend_hash_index_update(Z_ARRVAL_P(arr), key, &BG(active_ini_file_section), sizeof(zval *), NULL);
+                       }
                        break;
        }
 }