summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerick Rethans <derick@php.net>2007-12-18 10:53:39 +0000
committerDerick Rethans <derick@php.net>2007-12-18 10:53:39 +0000
commit9541a66cb8182deb3b6f2c44375aae824bf2a019 (patch)
tree837aa1b2b9bbb9b37ae8c54ed8e42658a024b040
parent31fb02db2e0e57249302e481638f94a47e815dd0 (diff)
downloadphp-git-9541a66cb8182deb3b6f2c44375aae824bf2a019.tar.gz
- MFH: Fixed var_export() for array keys
- MFH: Fixed broken explode() test
-rw-r--r--ext/standard/tests/array/bug26458.phptbin395 -> 406 bytes
-rw-r--r--ext/standard/tests/array/var_export2.phptbin204 -> 215 bytes
-rw-r--r--ext/standard/tests/strings/explode.phpt9
-rw-r--r--ext/standard/var.c8
4 files changed, 13 insertions, 4 deletions
diff --git a/ext/standard/tests/array/bug26458.phpt b/ext/standard/tests/array/bug26458.phpt
index d24e1f151b..ecd12ba843 100644
--- a/ext/standard/tests/array/bug26458.phpt
+++ b/ext/standard/tests/array/bug26458.phpt
Binary files differ
diff --git a/ext/standard/tests/array/var_export2.phpt b/ext/standard/tests/array/var_export2.phpt
index 2b8a1f97ef..6db44d5ca1 100644
--- a/ext/standard/tests/array/var_export2.phpt
+++ b/ext/standard/tests/array/var_export2.phpt
Binary files differ
diff --git a/ext/standard/tests/strings/explode.phpt b/ext/standard/tests/strings/explode.phpt
index defb79c229..6d54b66090 100644
--- a/ext/standard/tests/strings/explode.phpt
+++ b/ext/standard/tests/strings/explode.phpt
@@ -5,6 +5,7 @@ error_reporting=2047
--FILE--
<?php
/* From http://bugs.php.net/19865 */
+echo var_export(explode("\1", "a". chr(1). "b". chr(0). "d" . chr(1) . "f" . chr(1). "1" . chr(1) . "d"), TRUE);
echo md5(var_export(explode("\1", "a". chr(1). "b". chr(0). "d" . chr(1) . "f" . chr(1). "1" . chr(1) . "d"), TRUE));
echo "\n";
var_dump(@explode("", ""));
@@ -29,7 +30,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)
diff --git a/ext/standard/var.c b/ext/standard/var.c
index c416e8af98..6a3f1290a0 100644
--- a/ext/standard/var.c
+++ b/ext/standard/var.c
@@ -353,13 +353,15 @@ static int php_array_element_export(zval **zv, int num_args, va_list args, zend_
if (hash_key->nKeyLength == 0) { /* numeric key */
php_printf("%*c%ld => ", level + 1, ' ', hash_key->h);
} else { /* string key */
- char *key;
- int key_len;
+ char *key, *tmp_str;
+ int key_len, tmp_len;
key = php_addcslashes(hash_key->arKey, hash_key->nKeyLength - 1, &key_len, 0, "'\\", 2 TSRMLS_CC);
+ tmp_str = php_str_to_str_ex(key, key_len, "\0", 1, "' . \"\\0\" . '", 12, &tmp_len, 0, NULL);
php_printf("%*c'", level + 1, ' ');
- PHPWRITE(key, key_len);
+ PHPWRITE(tmp_str, tmp_len);
php_printf("' => ");
efree(key);
+ efree(tmp_str);
}
php_var_export(zv, level + 2 TSRMLS_CC);
PUTS (",\n");