]> granicus.if.org Git - php/commitdiff
Fixed bug #41527 (WDDX deserialize numeric string array key).
authorIlia Alshanetsky <iliaa@php.net>
Mon, 11 Jun 2007 15:08:43 +0000 (15:08 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 11 Jun 2007 15:08:43 +0000 (15:08 +0000)
NEWS
ext/wddx/tests/bug41527.phpt [new file with mode: 0644]
ext/wddx/wddx.c

diff --git a/NEWS b/NEWS
index 1fbaf6ce8ef14bd5079403f168329f9dec486323..4d3fd5da985f5daf7c0f9e88c7f0c5e44dc83fd7 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -42,6 +42,8 @@ PHP                                                                        NEWS
   with ini_set()). (Tony, Dmitry)
 - Fixed bug #41555 (configure failure: regression caused by fix for #41265).
   (Jani)
+- Fixed bug #41527 (WDDX deserialize numeric string array key). (php_lists
+  at realplain dot com, Ilia)
 - Fixed bug #41518 (file_exists() warns of open_basedir restriction on 
   non-existent file). (Tony)
 - Fixed bug #39330 (apache2handler does not call shutdown actions before 
diff --git a/ext/wddx/tests/bug41527.phpt b/ext/wddx/tests/bug41527.phpt
new file mode 100644 (file)
index 0000000..447bfc3
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+Bug #41527 (WDDX deserialize numeric string array keys)
+--SKIPIF--
+<?php if (!extension_loaded("wddx")) print "skip"; ?>
+--FILE--
+<?php
+$data = array('01' => 'Zero', '+1' => 'Plus sign', ' 1' => 'Space');
+
+var_dump(wddx_deserialize(wddx_serialize_vars('data')));
+?>
+--EXPECT--
+array(1) {
+  ["data"]=>
+  array(3) {
+    ["01"]=>
+    string(4) "Zero"
+    ["+1"]=>
+    string(9) "Plus sign"
+    [" 1"]=>
+    string(5) "Space"
+  }
+}
index b3acc553e02e51c5e4794cbc4d0f634b9a095169..a3ff9870bfe4f9bbdeb9ab76dd7889e3883bb07f 100644 (file)
@@ -974,26 +974,7 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name)
                                                add_property_zval(ent2->data, ent1->varname, ent1->data);
                                                EG(scope) = old_scope;
                                        } else {
-                                               long l;
-                                               double d;
-                                               int varname_len = strlen(ent1->varname);
-                               
-                                               switch (is_numeric_string(ent1->varname, varname_len, &l, &d, 0)) {
-                                                       case IS_DOUBLE:
-                                                               if (d > INT_MAX) {
-                                                                       goto bigint;
-                                                               }
-                                                               l = (long) d;
-                                                               if (l != d) {
-                                                                       goto bigint;
-                                                               }
-                                                       case IS_LONG:
-                                                               zend_hash_index_update(target_hash, l, &ent1->data, sizeof(zval *), NULL);
-                                                               break;
-                                                       default:
-bigint:
-                                                               zend_hash_update(target_hash,ent1->varname, varname_len + 1, &ent1->data, sizeof(zval *), NULL);
-                                               }
+                                               zend_symtable_update(target_hash, ent1->varname, strlen(ent1->varname)+1, &ent1->data, sizeof(zval *), NULL);
                                        }
                                        efree(ent1->varname);
                                } else  {