]> granicus.if.org Git - php/commitdiff
- Fixed var_export() for array keys
authorDerick Rethans <derick@php.net>
Tue, 18 Dec 2007 10:53:25 +0000 (10:53 +0000)
committerDerick Rethans <derick@php.net>
Tue, 18 Dec 2007 10:53:25 +0000 (10:53 +0000)
- Fixed broken explode() test

ext/standard/tests/array/bug26458.phpt
ext/standard/tests/array/var_export2.phpt
ext/standard/tests/strings/explode.phpt
ext/standard/var.c

index 105caee0de7eeb98f4017d8ac81b8c803b3b1d34..c1d1ef71bf2531c329cc333df59071b3901c9090 100644 (file)
Binary files a/ext/standard/tests/array/bug26458.phpt and b/ext/standard/tests/array/bug26458.phpt differ
index 2b8a1f97ef9b2daf7588552bbf71450b2fa38b03..6db44d5ca1172bde49397c6c2657662fbc39d372 100644 (file)
Binary files a/ext/standard/tests/array/var_export2.phpt and b/ext/standard/tests/array/var_export2.phpt differ
index 103ee227efd2e2326e6572e5546c454b92e25c70..488ce2ff88dcf0848aee030c80a9f143082369f7 100644 (file)
@@ -6,6 +6,7 @@ error_reporting=2047
 <?php
 /* From http://bugs.php.net/19865 */
 $s = (binary) var_export(explode(b"\1", (binary)"a". chr(1). "b". chr(0). "d" . chr(1) . "f" . chr(1). "1" . chr(1) . "d"), TRUE);
+echo $s;
 echo md5($s);
 echo "\n";
 var_dump(@explode("", ""));
@@ -30,7 +31,13 @@ var_dump(explode(":^:","a lazy dog:^:jumps::over:^:",-1));
 var_dump(explode(":^:","a lazy dog:^:jumps::over:^:",-2));
 ?>
 --EXPECTF--
-6e5d59d5afd6693547a733219d079658
+array (
+  0 => 'a',
+  1 => 'b' . "\0" . 'd',
+  2 => 'f',
+  3 => '1',
+  4 => 'd',
+)d6bee42a771449205344c0938ad4f035
 bool(false)
 bool(false)
 bool(false)
@@ -154,7 +161,13 @@ array(1) {
   string(10) "a lazy dog"
 }
 --UEXPECTF--
-6e5d59d5afd6693547a733219d079658
+array (
+  0 => 'a',
+  1 => 'b' . "\0" . 'd',
+  2 => 'f',
+  3 => '1',
+  4 => 'd',
+)d6bee42a771449205344c0938ad4f035
 bool(false)
 bool(false)
 bool(false)
index 353edef33d4656a54f2b5039768b921eb50ff364..8e4d9d2c9017108f9a59bbfccc6c14c6e5ff0bd1 100644 (file)
@@ -480,12 +480,13 @@ static int php_array_element_export(zval **zv, int num_args, va_list args, zend_
                if (hash_key->type == IS_UNICODE) {
                        php_var_dump_unicode(hash_key->arKey.u, hash_key->nKeyLength-1, 0, "", 1 TSRMLS_CC);
                } else {
-                       char *key;
-                       int key_len;
-
+                       char *key, *tmp_str;
+                       int key_len, tmp_len;
                        key = php_addcslashes(hash_key->arKey.s, hash_key->nKeyLength - 1, &key_len, 0, "'\\", 2 TSRMLS_CC);
-                       PHPWRITE(key, key_len);
+                       tmp_str = php_str_to_str_ex(key, key_len, "\0", 1, "' . \"\\0\" . '", 12, &tmp_len, 0, NULL);
+                       PHPWRITE(tmp_str, tmp_len);
                        efree(key);
+                       efree(tmp_str);
                }
                php_printf("' => ");
        }