zend_test: zend_test_compile_string converting script argument to path. (#17810)

This commit is contained in:
David CARLIER 2025-02-15 11:15:08 +00:00 committed by GitHub
parent 01a87e0d2d
commit d3da2a2884
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View file

@ -243,7 +243,7 @@ static ZEND_FUNCTION(zend_test_compile_string)
ZEND_PARSE_PARAMETERS_START(3, 3)
Z_PARAM_STR(source_string)
Z_PARAM_STR(filename)
Z_PARAM_PATH_STR_EX(filename, 1, 0)
Z_PARAM_LONG(position)
ZEND_PARSE_PARAMETERS_END();

View file

@ -38,12 +38,25 @@ EOF;
zend_test_compile_string($source_string, 'Source string', ZEND_COMPILE_POSITION_AFTER_OPEN_TAG);
$source_string = <<<EOF
<?php
var_dump('php');
EOF;
try {
zend_test_compile_string($source_string, "Sources\0string", ZEND_COMPILE_POSITION_AT_OPEN_TAG);
} catch (\ValueError $e) {
echo $e->getMessage(), PHP_EOL;
}
$source_string = <<<EOF
<?php
var_dump('php');
EOF;
zend_test_compile_string($source_string, 'Source string', ZEND_COMPILE_POSITION_AFTER_OPEN_TAG);
?>
--EXPECT--
string(3) "php"
@ -51,5 +64,6 @@ string(3) "php"
string(3) "php"
string(3) "php"
string(3) "php"
zend_test_compile_string(): Argument #2 ($filename) must not contain any null bytes
Parse error: syntax error, unexpected token "<", expecting end of file in Source string on line 1