From: Ilia Alshanetsky Date: Wed, 8 Oct 2003 01:17:12 +0000 (+0000) Subject: MFH: Fixed bug #25758 (var_export does not escape ' & \ inside array keys) X-Git-Tag: php-4.3.4RC2~37 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=116956cc648f3a13007df1f80904b308968fc8ec;p=php MFH: Fixed bug #25758 (var_export does not escape ' & \ inside array keys) --- diff --git a/NEWS b/NEWS index a532bac445..12b0f3d309 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ PHP 4 NEWS POSIX compatible mode. (K.Kosako , Moriyoshi) - Fixed bug #25770 (Segfault with PHP and bison 1.875). (eggert@gnu.org, Marcus) - Fixed bug #25764 (ldap_get_option() crashes with unbound ldap link). (Jani) +- Fixed bug #25758 (var_export does not escape ' & \ inside array keys). (Ilia) - Fixed bug #25752 (ext/ncurses: ncurses.h instead of curses.h with BSD). (Jani) - Fixed bug #25745 (ctype functions fail with non-ascii characters). (Moriyoshi) - Fixed bug #25744 (make ZTS build of ext/sybase compile). (Ilia) diff --git a/ext/standard/var.c b/ext/standard/var.c index 4ff537a5e6..d324da74a6 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -256,7 +256,11 @@ 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 */ - php_printf("%*c'%s' => ", level + 1, ' ', hash_key->arKey); + char *key; + int key_len; + key = php_addcslashes(hash_key->arKey, strlen(hash_key->arKey), &key_len, 0, "'\\", 2 TSRMLS_CC); + php_printf("%*c'%s' => ", level + 1, ' ', key); + efree(key); } php_var_export(zv, level + 2 TSRMLS_CC); PUTS (",\n");