iliaa Tue Oct 7 21:16:45 2003 EDT
Added files:
/php-src/ext/standard/tests/array bug25758.phpt
Modified files:
/php-src/ext/standard var.c
Log:
Fixed bug #25758 (var_export does not escape ' & \ inside array keys)
Index: php-src/ext/standard/var.c
diff -u php-src/ext/standard/var.c:1.171 php-src/ext/standard/var.c:1.172
--- php-src/ext/standard/var.c:1.171 Thu Aug 28 12:28:33 2003
+++ php-src/ext/standard/var.c Tue Oct 7 21:16:44 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: var.c,v 1.171 2003/08/28 16:28:33 sas Exp $ */
+/* $Id: var.c,v 1.172 2003/10/08 01:16:44 iliaa Exp $ */
/* {{{ includes
@@ -271,7 +271,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