iliaa           Tue Oct  7 21:17:13 2003 EDT

  Added files:                 (Branch: PHP_4_3)
    /php-src/ext/standard/tests/array   bug25758.phpt 

  Modified files:              
    /php-src    NEWS 
    /php-src/ext/standard       var.c 
  Log:
  MFH: Fixed bug #25758 (var_export does not escape ' & \ inside array keys)
  
  
Index: php-src/NEWS
diff -u php-src/NEWS:1.1247.2.428 php-src/NEWS:1.1247.2.429
--- php-src/NEWS:1.1247.2.428   Tue Oct  7 06:04:51 2003
+++ php-src/NEWS        Tue Oct  7 21:17:11 2003
@@ -5,6 +5,7 @@
   POSIX compatible mode. (K.Kosako <kosako at sofnec.co.jp>, Moriyoshi)
 - Fixed bug #25770 (Segfault with PHP and bison 1.875). ([EMAIL PROTECTED], 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: php-src/ext/standard/var.c
diff -u php-src/ext/standard/var.c:1.150.2.10 php-src/ext/standard/var.c:1.150.2.11
--- php-src/ext/standard/var.c:1.150.2.10       Thu Aug 28 12:01:49 2003
+++ php-src/ext/standard/var.c  Tue Oct  7 21:17:11 2003
@@ -256,7 +256,11 @@
        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");

Index: php-src/ext/standard/tests/array/bug25758.phpt
+++ php-src/ext/standard/tests/array/bug25758.phpt
--TEST--
Bug #25758 (var_export does not escape ' & \ inside array keys)
--FILE--
<?php
        $a = array ("quote'" => array("quote'"));
        echo var_export($a, true);
?>
--EXPECT--
array (
  'quote\'' => 
  array (
    0 => 'quote\'',
  ),
)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to