From dc30b0035d098b6e982c432c8d81919524f1d9fd Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Wed, 19 Dec 2007 08:45:16 +0000 Subject: [PATCH] - MFH: Fixed var_export() for array keys - MFH: Fixed broken explode() test --- ext/standard/tests/array/bug26458.phpt | Bin 395 -> 406 bytes ext/standard/tests/array/var_export2.phpt | Bin 204 -> 215 bytes ext/standard/tests/strings/explode.phpt | 9 ++++++++- ext/standard/var.c | 8 +++++--- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ext/standard/tests/array/bug26458.phpt b/ext/standard/tests/array/bug26458.phpt index d24e1f151b01ed08cee72a60d760ba87a9c06332..ecd12ba843d3fc1d0982049370adfa27ac3309d4 100644 GIT binary patch delta 24 ecmeBXp2oaElaWVVK~F&`#y|;3sZZ8oOauT#H3cUC delta 13 UcmbQn+|9f}laY~OvMFOC02sLgEdT%j diff --git a/ext/standard/tests/array/var_export2.phpt b/ext/standard/tests/array/var_export2.phpt index 2b8a1f97ef9b2daf7588552bbf71450b2fa38b03..6db44d5ca1172bde49397c6c2657662fbc39d372 100644 GIT binary patch delta 22 ccmX@Zc%5;=Tpo1=Jq4v010^7(K5?EN08QBjHUIzs delta 11 Scmcc4c!qJpTtyTm(D- 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"); -- 2.40.0