MFB: Fixed bug #37262 (var_export() does not escape \0 character).

This commit is contained in:
Ilia Alshanetsky 2006-10-09 18:09:42 +00:00
parent 31212f9c0b
commit e8ccee4873
3 changed files with 11 additions and 2 deletions

View File

@ -0,0 +1,9 @@
--TEST--
Bug #37262 (var_export() does not escape \0 character)
--FILE--
<?php
$func = create_function('$a', 'return $a;');
var_export($func);
?>
--EXPECT--
'\000lambda_1'

View File

@ -29,7 +29,7 @@ var_dump(explode(":^:","a lazy dog:^:jumps::over:^:",-1));
var_dump(explode(":^:","a lazy dog:^:jumps::over:^:",-2));
?>
--EXPECTF--
26d4e18734cb2582df5055e2175223df
6e5d59d5afd6693547a733219d079658
bool(false)
bool(false)
bool(false)

View File

@ -543,7 +543,7 @@ PHPAPI void php_var_export(zval **struc, int level TSRMLS_DC)
php_printf("%.*G", (int) EG(precision), Z_DVAL_PP(struc));
break;
case IS_STRING:
tmp_str = php_addcslashes(Z_STRVAL_PP(struc), Z_STRLEN_PP(struc), &tmp_len, 0, "'\\", 2 TSRMLS_CC);
tmp_str = php_addcslashes(Z_STRVAL_PP(struc), Z_STRLEN_PP(struc), &tmp_len, 0, "'\\\0", 3 TSRMLS_CC);
PUTS ("'");
PHPWRITE(tmp_str, tmp_len);
PUTS ("'");