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

index 241101f2a40afc581740a555f5a3a033397bc978..af716d1893f343430032b4b011f253c925197f7e 100644 (file)
@@ -20,7 +20,7 @@ array(1) {
       string(5) "One 1"
       ["1.2"]=>
       string(5) "One 2"
-      [1]=>
+      ["1.0"]=>
       string(5) "Three"
     }
   }
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 0282da2fde7c8d6fa17adf4fcc7d04b82e50298a..0c1aedf1eb6ce4c4c3f00689a04f7e57ac784812 100644 (file)
@@ -975,25 +975,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;
-                               
-                                               switch (is_numeric_string(ent1->varname, strlen(ent1->varname), &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, strlen(ent1->varname)+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  {