Skip to content

Commit d3da2a2

Browse files
authored
zend_test: zend_test_compile_string converting script argument to path. (#17810)
1 parent 01a87e0 commit d3da2a2

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

ext/zend_test/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ static ZEND_FUNCTION(zend_test_compile_string)
243243

244244
ZEND_PARSE_PARAMETERS_START(3, 3)
245245
Z_PARAM_STR(source_string)
246-
Z_PARAM_STR(filename)
246+
Z_PARAM_PATH_STR_EX(filename, 1, 0)
247247
Z_PARAM_LONG(position)
248248
ZEND_PARSE_PARAMETERS_END();
249249

ext/zend_test/tests/zend_test_compile_string.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,32 @@ EOF;
3838

3939
zend_test_compile_string($source_string, 'Source string', ZEND_COMPILE_POSITION_AFTER_OPEN_TAG);
4040

41+
$source_string = <<<EOF
42+
<?php
43+
var_dump('php');
44+
EOF;
45+
46+
try {
47+
zend_test_compile_string($source_string, "Sources\0string", ZEND_COMPILE_POSITION_AT_OPEN_TAG);
48+
} catch (\ValueError $e) {
49+
echo $e->getMessage(), PHP_EOL;
50+
}
51+
52+
4153
$source_string = <<<EOF
4254
<?php
4355
var_dump('php');
4456
EOF;
4557

4658
zend_test_compile_string($source_string, 'Source string', ZEND_COMPILE_POSITION_AFTER_OPEN_TAG);
59+
4760
?>
4861
--EXPECT--
4962
string(3) "php"
5063
#!/path/to/php
5164
string(3) "php"
5265
string(3) "php"
5366
string(3) "php"
67+
zend_test_compile_string(): Argument #2 ($filename) must not contain any null bytes
5468

5569
Parse error: syntax error, unexpected token "<", expecting end of file in Source string on line 1

0 commit comments

Comments
 (0)