1
0
mirror of https://github.com/php/php-src.git synced 2026-04-08 00:22:52 +02:00

- Fixed bug #55082 (var_export() doesn't escape properties properly).

This commit is contained in:
Gustavo André dos Santos Lopes
2011-06-30 09:26:35 +00:00
parent 3f3ae34fc2
commit 404686447b
2 changed files with 22 additions and 3 deletions

View File

@@ -0,0 +1,11 @@
--TEST--
Bug #55082: var_export() doesn't escape properties properly
--FILE--
<?php
$x = new stdClass();
$x->{'\'\\'} = 7;
echo var_export($x);
--EXPECT--
stdClass::__set_state(array(
'\'\\' => 7,
))

View File

@@ -384,18 +384,26 @@ static int php_object_element_export(zval **zv TSRMLS_DC, int num_args, va_list
{
int level;
smart_str *buf;
char *prop_name, *class_name;
level = va_arg(args, int);
buf = va_arg(args, smart_str *);
buffer_append_spaces(buf, level + 2);
if (hash_key->nKeyLength != 0) {
zend_unmangle_property_name(hash_key->arKey, hash_key->nKeyLength - 1, &class_name, &prop_name);
char *class_name, /* ignored, but must be passed to unmangle */
*pname,
*pname_esc;
int pname_esc_len;
zend_unmangle_property_name(hash_key->arKey, hash_key->nKeyLength - 1,
&class_name, &pname);
pname_esc = php_addcslashes(pname, strlen(pname), &pname_esc_len, 0,
"'\\", 2 TSRMLS_CC);
smart_str_appendc(buf, '\'');
smart_str_appends(buf, prop_name);
smart_str_appendl(buf, pname_esc, pname_esc_len);
smart_str_appendc(buf, '\'');
efree(pname_esc);
} else {
smart_str_append_long(buf, (long) hash_key->h);
}