From: Derick Rethans Date: Wed, 19 Dec 2007 08:45:16 +0000 (+0000) Subject: - MFH: Fixed var_export() for array keys X-Git-Tag: php-5.2.6RC1~234 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dc30b0035d098b6e982c432c8d81919524f1d9fd;p=php - MFH: Fixed var_export() for array keys - MFH: Fixed broken explode() test --- diff --git a/ext/standard/tests/array/bug26458.phpt b/ext/standard/tests/array/bug26458.phpt index d24e1f151b..ecd12ba843 100644 Binary files a/ext/standard/tests/array/bug26458.phpt and b/ext/standard/tests/array/bug26458.phpt differ diff --git a/ext/standard/tests/array/var_export2.phpt b/ext/standard/tests/array/var_export2.phpt index 2b8a1f97ef..6db44d5ca1 100644 Binary files a/ext/standard/tests/array/var_export2.phpt and b/ext/standard/tests/array/var_export2.phpt 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-- --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 907589468b..66a037ab56 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -355,13 +355,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");