]> granicus.if.org Git - php/commitdiff
MFH: Fixed bug #25758 (var_export does not escape ' & \ inside array keys)
authorIlia Alshanetsky <iliaa@php.net>
Wed, 8 Oct 2003 01:17:12 +0000 (01:17 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 8 Oct 2003 01:17:12 +0000 (01:17 +0000)
NEWS
ext/standard/var.c

diff --git a/NEWS b/NEWS
index a532bac445e97cf788466f3fc84f466965110710..12b0f3d30987efd0b3019c5b078b7bb2fa166c89 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ PHP 4                                                                      NEWS
   POSIX compatible mode. (K.Kosako <kosako at sofnec.co.jp>, 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)
index 4ff537a5e6deee13f4e09f846d36366adc08519b..d324da74a6e43b22d086ea7ed41bc333ab4971ca 100644 (file)
@@ -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");