- 添加GH-16630 UAF漏洞相关编码转换和heredoc测试 - 添加基本heredoc语法测试用例 - 添加二进制heredoc语法测试用例 - 添加变量替换相关heredoc测试用例 - 添加复杂变量替换相关heredoc测试用例 - 添加半保留字作为静态类方法的测试用例 - 添加公共测试辅助文件nowdoc.inc - 添加示例代码文件lv3_prop.php和prop.phppull/1/head
parent
166f53f28e
commit
3959fee828
10 changed files with 415 additions and 0 deletions
@ -0,0 +1,11 @@ |
||||
<?php |
||||
function main() |
||||
{ |
||||
$o = new stdClass(); |
||||
$o->prop = ['dim2' => ['dim3' => 'value']]; |
||||
$o->prop['dim2']['dim3'] = 'hello'; |
||||
|
||||
var_dump($o); |
||||
} |
||||
|
||||
|
||||
@ -0,0 +1,8 @@ |
||||
<?php |
||||
function main() |
||||
{ |
||||
$o = new stdClass; |
||||
$o->a = 1024; |
||||
$o->a *= 2; |
||||
var_dump($o->a); |
||||
} |
||||
@ -0,0 +1,245 @@ |
||||
--TEST-- |
||||
Test semi-reserved words as static class methods |
||||
--FILE-- |
||||
<?php |
||||
|
||||
class Obj |
||||
{ |
||||
static function empty(){ echo __METHOD__, PHP_EOL; } |
||||
static function callable(){ echo __METHOD__, PHP_EOL; } |
||||
static function class(){ echo __METHOD__, PHP_EOL; } |
||||
static function trait(){ echo __METHOD__, PHP_EOL; } |
||||
static function extends(){ echo __METHOD__, PHP_EOL; } |
||||
static function implements(){ echo __METHOD__, PHP_EOL; } |
||||
static function static(){ echo __METHOD__, PHP_EOL; } |
||||
static function abstract(){ echo __METHOD__, PHP_EOL; } |
||||
static function final(){ echo __METHOD__, PHP_EOL; } |
||||
static function public(){ echo __METHOD__, PHP_EOL; } |
||||
static function protected(){ echo __METHOD__, PHP_EOL; } |
||||
static function private(){ echo __METHOD__, PHP_EOL; } |
||||
static function const(){ echo __METHOD__, PHP_EOL; } |
||||
static function enddeclare(){ echo __METHOD__, PHP_EOL; } |
||||
static function endfor(){ echo __METHOD__, PHP_EOL; } |
||||
static function endforeach(){ echo __METHOD__, PHP_EOL; } |
||||
static function endif(){ echo __METHOD__, PHP_EOL; } |
||||
static function endwhile(){ echo __METHOD__, PHP_EOL; } |
||||
static function and(){ echo __METHOD__, PHP_EOL; } |
||||
static function global(){ echo __METHOD__, PHP_EOL; } |
||||
static function goto(){ echo __METHOD__, PHP_EOL; } |
||||
static function instanceof(){ echo __METHOD__, PHP_EOL; } |
||||
static function insteadof(){ echo __METHOD__, PHP_EOL; } |
||||
static function interface(){ echo __METHOD__, PHP_EOL; } |
||||
static function namespace(){ echo __METHOD__, PHP_EOL; } |
||||
static function new(){ echo __METHOD__, PHP_EOL; } |
||||
static function or(){ echo __METHOD__, PHP_EOL; } |
||||
static function xor(){ echo __METHOD__, PHP_EOL; } |
||||
static function try(){ echo __METHOD__, PHP_EOL; } |
||||
static function use(){ echo __METHOD__, PHP_EOL; } |
||||
static function var(){ echo __METHOD__, PHP_EOL; } |
||||
static function exit(){ echo __METHOD__, PHP_EOL; } |
||||
static function list(){ echo __METHOD__, PHP_EOL; } |
||||
static function clone(){ echo __METHOD__, PHP_EOL; } |
||||
static function include(){ echo __METHOD__, PHP_EOL; } |
||||
static function include_once(){ echo __METHOD__, PHP_EOL; } |
||||
static function throw(){ echo __METHOD__, PHP_EOL; } |
||||
static function array(){ echo __METHOD__, PHP_EOL; } |
||||
static function print(){ echo __METHOD__, PHP_EOL; } |
||||
static function echo(){ echo __METHOD__, PHP_EOL; } |
||||
static function require(){ echo __METHOD__, PHP_EOL; } |
||||
static function require_once(){ echo __METHOD__, PHP_EOL; } |
||||
static function return(){ echo __METHOD__, PHP_EOL; } |
||||
static function else(){ echo __METHOD__, PHP_EOL; } |
||||
static function elseif(){ echo __METHOD__, PHP_EOL; } |
||||
static function default(){ echo __METHOD__, PHP_EOL; } |
||||
static function break(){ echo __METHOD__, PHP_EOL; } |
||||
static function continue(){ echo __METHOD__, PHP_EOL; } |
||||
static function switch(){ echo __METHOD__, PHP_EOL; } |
||||
static function yield(){ echo __METHOD__, PHP_EOL; } |
||||
static function function(){ echo __METHOD__, PHP_EOL; } |
||||
static function fn(){ echo __METHOD__, PHP_EOL; } |
||||
static function if(){ echo __METHOD__, PHP_EOL; } |
||||
static function endswitch(){ echo __METHOD__, PHP_EOL; } |
||||
static function finally(){ echo __METHOD__, PHP_EOL; } |
||||
static function for(){ echo __METHOD__, PHP_EOL; } |
||||
static function foreach(){ echo __METHOD__, PHP_EOL; } |
||||
static function declare(){ echo __METHOD__, PHP_EOL; } |
||||
static function case(){ echo __METHOD__, PHP_EOL; } |
||||
static function do(){ echo __METHOD__, PHP_EOL; } |
||||
static function while(){ echo __METHOD__, PHP_EOL; } |
||||
static function as(){ echo __METHOD__, PHP_EOL; } |
||||
static function catch(){ echo __METHOD__, PHP_EOL; } |
||||
static function die(){ echo __METHOD__, PHP_EOL; } |
||||
static function self(){ echo __METHOD__, PHP_EOL; } |
||||
static function parent(){ echo __METHOD__, PHP_EOL; } |
||||
static function isset(){ echo __METHOD__, PHP_EOL; } |
||||
static function unset(){ echo __METHOD__, PHP_EOL; } |
||||
static function __CLASS__(){ echo __METHOD__, PHP_EOL; } |
||||
static function __TRAIT__(){ echo __METHOD__, PHP_EOL; } |
||||
static function __FUNCTION__(){ echo __METHOD__, PHP_EOL; } |
||||
static function __METHOD__(){ echo __METHOD__, PHP_EOL; } |
||||
static function __LINE__(){ echo __METHOD__, PHP_EOL; } |
||||
static function __FILE__(){ echo __METHOD__, PHP_EOL; } |
||||
static function __DIR__(){ echo __METHOD__, PHP_EOL; } |
||||
static function __NAMESPACE__(){ echo __METHOD__, PHP_EOL; } |
||||
} |
||||
|
||||
function main() { |
||||
Obj::empty(); |
||||
Obj::callable(); |
||||
Obj::class(); |
||||
Obj::trait(); |
||||
Obj::extends(); |
||||
Obj::implements(); |
||||
Obj::static(); |
||||
Obj::abstract(); |
||||
Obj::final(); |
||||
Obj::public(); |
||||
Obj::protected(); |
||||
Obj::private(); |
||||
Obj::const(); |
||||
Obj::enddeclare(); |
||||
Obj::endfor(); |
||||
Obj::endforeach(); |
||||
Obj::endif(); |
||||
Obj::endwhile(); |
||||
Obj::and(); |
||||
Obj::global(); |
||||
Obj::goto(); |
||||
Obj::instanceof(); |
||||
Obj::insteadof(); |
||||
Obj::interface(); |
||||
Obj::namespace(); |
||||
Obj::new(); |
||||
Obj::or(); |
||||
Obj::xor(); |
||||
Obj::try(); |
||||
Obj::use(); |
||||
Obj::var(); |
||||
Obj::exit(); |
||||
Obj::list(); |
||||
Obj::clone(); |
||||
Obj::include(); |
||||
Obj::include_once(); |
||||
Obj::throw(); |
||||
Obj::array(); |
||||
Obj::print(); |
||||
Obj::echo(); |
||||
Obj::require(); |
||||
Obj::require_once(); |
||||
Obj::return(); |
||||
Obj::else(); |
||||
Obj::elseif(); |
||||
Obj::default(); |
||||
Obj::break(); |
||||
Obj::continue(); |
||||
Obj::switch(); |
||||
Obj::yield(); |
||||
Obj::function(); |
||||
Obj::fn(); |
||||
Obj::if(); |
||||
Obj::endswitch(); |
||||
Obj::finally(); |
||||
Obj::for(); |
||||
Obj::foreach(); |
||||
Obj::declare(); |
||||
Obj::case(); |
||||
Obj::do(); |
||||
Obj::while(); |
||||
Obj::as(); |
||||
Obj::catch(); |
||||
Obj::die(); |
||||
Obj::self(); |
||||
Obj::parent(); |
||||
Obj::isset(); |
||||
Obj::unset(); |
||||
Obj::__CLASS__(); |
||||
Obj::__TRAIT__(); |
||||
Obj::__FUNCTION__(); |
||||
Obj::__METHOD__(); |
||||
Obj::__LINE__(); |
||||
Obj::__FILE__(); |
||||
Obj::__DIR__(); |
||||
Obj::__NAMESPACE__(); |
||||
|
||||
echo "\nDone\n"; |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
Obj::empty |
||||
Obj::callable |
||||
Obj::class |
||||
Obj::trait |
||||
Obj::extends |
||||
Obj::implements |
||||
Obj::static |
||||
Obj::abstract |
||||
Obj::final |
||||
Obj::public |
||||
Obj::protected |
||||
Obj::private |
||||
Obj::const |
||||
Obj::enddeclare |
||||
Obj::endfor |
||||
Obj::endforeach |
||||
Obj::endif |
||||
Obj::endwhile |
||||
Obj::and |
||||
Obj::global |
||||
Obj::goto |
||||
Obj::instanceof |
||||
Obj::insteadof |
||||
Obj::interface |
||||
Obj::namespace |
||||
Obj::new |
||||
Obj::or |
||||
Obj::xor |
||||
Obj::try |
||||
Obj::use |
||||
Obj::var |
||||
Obj::exit |
||||
Obj::list |
||||
Obj::clone |
||||
Obj::include |
||||
Obj::include_once |
||||
Obj::throw |
||||
Obj::array |
||||
Obj::print |
||||
Obj::echo |
||||
Obj::require |
||||
Obj::require_once |
||||
Obj::return |
||||
Obj::else |
||||
Obj::elseif |
||||
Obj::default |
||||
Obj::break |
||||
Obj::continue |
||||
Obj::switch |
||||
Obj::yield |
||||
Obj::function |
||||
Obj::fn |
||||
Obj::if |
||||
Obj::endswitch |
||||
Obj::finally |
||||
Obj::for |
||||
Obj::foreach |
||||
Obj::declare |
||||
Obj::case |
||||
Obj::do |
||||
Obj::while |
||||
Obj::as |
||||
Obj::catch |
||||
Obj::die |
||||
Obj::self |
||||
Obj::parent |
||||
Obj::isset |
||||
Obj::unset |
||||
Obj::__CLASS__ |
||||
Obj::__TRAIT__ |
||||
Obj::__FUNCTION__ |
||||
Obj::__METHOD__ |
||||
Obj::__LINE__ |
||||
Obj::__FILE__ |
||||
Obj::__DIR__ |
||||
Obj::__NAMESPACE__ |
||||
|
||||
Done |
||||
@ -0,0 +1,19 @@ |
||||
--TEST-- |
||||
GH-16630 (UAF in lexer with encoding translation and heredocs) |
||||
--EXTENSIONS-- |
||||
mbstring |
||||
--INI-- |
||||
zend.multibyte=On |
||||
zend.script_encoding=ISO-8859-1 |
||||
internal_encoding=EUC-JP |
||||
--FILE-- |
||||
<?php |
||||
$data3 = <<<CODE |
||||
heredoc |
||||
text |
||||
CODE; |
||||
echo $data3; |
||||
?> |
||||
--EXPECT-- |
||||
heredoc |
||||
text |
||||
@ -0,0 +1,23 @@ |
||||
--TEST-- |
||||
basic heredoc syntax |
||||
--FILE-- |
||||
<?php |
||||
|
||||
require_once __DIR__ . '/nowdoc.inc'; |
||||
|
||||
print <<<ENDOFHEREDOC |
||||
This is a heredoc test. |
||||
|
||||
ENDOFHEREDOC; |
||||
|
||||
$x = <<<ENDOFHEREDOC |
||||
This is another heredoc test. |
||||
|
||||
ENDOFHEREDOC; |
||||
|
||||
print "{$x}"; |
||||
|
||||
?> |
||||
--EXPECT-- |
||||
This is a heredoc test. |
||||
This is another heredoc test. |
||||
@ -0,0 +1,23 @@ |
||||
--TEST-- |
||||
basic binary heredoc syntax |
||||
--FILE-- |
||||
<?php |
||||
|
||||
require_once __DIR__ . '/nowdoc.inc'; |
||||
|
||||
print b<<<ENDOFHEREDOC |
||||
This is a heredoc test. |
||||
|
||||
ENDOFHEREDOC; |
||||
|
||||
$x = b<<<ENDOFHEREDOC |
||||
This is another heredoc test. |
||||
|
||||
ENDOFHEREDOC; |
||||
|
||||
print "{$x}"; |
||||
|
||||
?> |
||||
--EXPECT-- |
||||
This is a heredoc test. |
||||
This is another heredoc test. |
||||
@ -0,0 +1,24 @@ |
||||
--TEST-- |
||||
simple variable replacement test (heredoc) |
||||
--FILE-- |
||||
<?php |
||||
|
||||
$a = 1; |
||||
$b = 2; |
||||
|
||||
print <<<ENDOFHEREDOC |
||||
This is heredoc test #$a. |
||||
|
||||
ENDOFHEREDOC; |
||||
|
||||
$x = <<<ENDOFHEREDOC |
||||
This is heredoc test #$b. |
||||
|
||||
ENDOFHEREDOC; |
||||
|
||||
print "{$x}"; |
||||
|
||||
?> |
||||
--EXPECT-- |
||||
This is heredoc test #1. |
||||
This is heredoc test #2. |
||||
@ -0,0 +1,24 @@ |
||||
--TEST-- |
||||
braces variable replacement test (heredoc) |
||||
--FILE-- |
||||
<?php |
||||
|
||||
$a = 1; |
||||
$b = 2; |
||||
|
||||
print <<<ENDOFHEREDOC |
||||
This is heredoc test #{$a}. |
||||
|
||||
ENDOFHEREDOC; |
||||
|
||||
$x = <<<ENDOFHEREDOC |
||||
This is heredoc test #{$b}. |
||||
|
||||
ENDOFHEREDOC; |
||||
|
||||
print "{$x}"; |
||||
|
||||
?> |
||||
--EXPECT-- |
||||
This is heredoc test #1. |
||||
This is heredoc test #2. |
||||
@ -0,0 +1,28 @@ |
||||
--TEST-- |
||||
unbraced complex variable replacement test (heredoc) |
||||
--FILE-- |
||||
<?php |
||||
function main() { |
||||
require_once __DIR__ . '/nowdoc.inc'; |
||||
|
||||
$a = 1; |
||||
$b = 2; |
||||
$c = array( 'c' => 3, ); |
||||
$d = new d; |
||||
|
||||
print <<<ENDOFHEREDOC |
||||
This is heredoc test #s $a, $b, {$c['c']}, and $d->d. |
||||
|
||||
ENDOFHEREDOC; |
||||
|
||||
$x = <<<ENDOFHEREDOC |
||||
This is heredoc test #s $a, $b, {$c['c']}, and $d->d. |
||||
|
||||
ENDOFHEREDOC; |
||||
|
||||
print "{$x}"; |
||||
} |
||||
?> |
||||
--EXPECTF-- |
||||
This is heredoc test #s 1, 2, 3, and 4. |
||||
This is heredoc test #s 1, 2, 3, and 4. |
||||
@ -0,0 +1,10 @@ |
||||
<?php |
||||
|
||||
// Common definitions for heredoc/nowdoc tests. |
||||
$a = 1; |
||||
$b = 2; |
||||
$c = array( 'c' => 3, ); |
||||
class d { public $d = 4; }; |
||||
$d = new d; |
||||
|
||||
?> |
||||
Loading…
Reference in new issue