From 3959fee82864d2ab50ddf1121e86b651d5d12623 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Wed, 21 Jan 2026 17:30:16 +0800 Subject: [PATCH] =?UTF-8?q?test(zend):=20=E6=B7=BB=E5=8A=A0heredoc?= =?UTF-8?q?=E8=AF=AD=E6=B3=95=E5=92=8C=E5=8D=8A=E4=BF=9D=E7=95=99=E5=AD=97?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加GH-16630 UAF漏洞相关编码转换和heredoc测试 - 添加基本heredoc语法测试用例 - 添加二进制heredoc语法测试用例 - 添加变量替换相关heredoc测试用例 - 添加复杂变量替换相关heredoc测试用例 - 添加半保留字作为静态类方法的测试用例 - 添加公共测试辅助文件nowdoc.inc - 添加示例代码文件lv3_prop.php和prop.php --- examples/lv3_prop.php | 11 + examples/prop.php | 8 + tests/zend/grammar/semi_reserved_002.phpt | 245 +++++++++++++++++++++ tests/zend/heredoc_nowdoc/gh16630.phpt | 19 ++ tests/zend/heredoc_nowdoc/heredoc_001.phpt | 23 ++ tests/zend/heredoc_nowdoc/heredoc_002.phpt | 23 ++ tests/zend/heredoc_nowdoc/heredoc_003.phpt | 24 ++ tests/zend/heredoc_nowdoc/heredoc_004.phpt | 24 ++ tests/zend/heredoc_nowdoc/heredoc_005.phpt | 28 +++ tests/zend/heredoc_nowdoc/nowdoc.inc | 10 + 10 files changed, 415 insertions(+) create mode 100644 examples/lv3_prop.php create mode 100644 examples/prop.php create mode 100644 tests/zend/grammar/semi_reserved_002.phpt create mode 100644 tests/zend/heredoc_nowdoc/gh16630.phpt create mode 100644 tests/zend/heredoc_nowdoc/heredoc_001.phpt create mode 100644 tests/zend/heredoc_nowdoc/heredoc_002.phpt create mode 100644 tests/zend/heredoc_nowdoc/heredoc_003.phpt create mode 100644 tests/zend/heredoc_nowdoc/heredoc_004.phpt create mode 100644 tests/zend/heredoc_nowdoc/heredoc_005.phpt create mode 100644 tests/zend/heredoc_nowdoc/nowdoc.inc diff --git a/examples/lv3_prop.php b/examples/lv3_prop.php new file mode 100644 index 00000000..1dcc3b2b --- /dev/null +++ b/examples/lv3_prop.php @@ -0,0 +1,11 @@ +prop = ['dim2' => ['dim3' => 'value']]; + $o->prop['dim2']['dim3'] = 'hello'; + + var_dump($o); +} + + diff --git a/examples/prop.php b/examples/prop.php new file mode 100644 index 00000000..7365ae9e --- /dev/null +++ b/examples/prop.php @@ -0,0 +1,8 @@ +a = 1024; + $o->a *= 2; + var_dump($o->a); +} \ No newline at end of file diff --git a/tests/zend/grammar/semi_reserved_002.phpt b/tests/zend/grammar/semi_reserved_002.phpt new file mode 100644 index 00000000..bfbd3ef8 --- /dev/null +++ b/tests/zend/grammar/semi_reserved_002.phpt @@ -0,0 +1,245 @@ +--TEST-- +Test semi-reserved words as static class methods +--FILE-- + +--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 diff --git a/tests/zend/heredoc_nowdoc/gh16630.phpt b/tests/zend/heredoc_nowdoc/gh16630.phpt new file mode 100644 index 00000000..62d6c995 --- /dev/null +++ b/tests/zend/heredoc_nowdoc/gh16630.phpt @@ -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-- + +--EXPECT-- +heredoc +text diff --git a/tests/zend/heredoc_nowdoc/heredoc_001.phpt b/tests/zend/heredoc_nowdoc/heredoc_001.phpt new file mode 100644 index 00000000..d9d640c3 --- /dev/null +++ b/tests/zend/heredoc_nowdoc/heredoc_001.phpt @@ -0,0 +1,23 @@ +--TEST-- +basic heredoc syntax +--FILE-- + +--EXPECT-- +This is a heredoc test. +This is another heredoc test. diff --git a/tests/zend/heredoc_nowdoc/heredoc_002.phpt b/tests/zend/heredoc_nowdoc/heredoc_002.phpt new file mode 100644 index 00000000..68844a48 --- /dev/null +++ b/tests/zend/heredoc_nowdoc/heredoc_002.phpt @@ -0,0 +1,23 @@ +--TEST-- +basic binary heredoc syntax +--FILE-- + +--EXPECT-- +This is a heredoc test. +This is another heredoc test. diff --git a/tests/zend/heredoc_nowdoc/heredoc_003.phpt b/tests/zend/heredoc_nowdoc/heredoc_003.phpt new file mode 100644 index 00000000..4cc97ba5 --- /dev/null +++ b/tests/zend/heredoc_nowdoc/heredoc_003.phpt @@ -0,0 +1,24 @@ +--TEST-- +simple variable replacement test (heredoc) +--FILE-- + +--EXPECT-- +This is heredoc test #1. +This is heredoc test #2. diff --git a/tests/zend/heredoc_nowdoc/heredoc_004.phpt b/tests/zend/heredoc_nowdoc/heredoc_004.phpt new file mode 100644 index 00000000..f4a67c9f --- /dev/null +++ b/tests/zend/heredoc_nowdoc/heredoc_004.phpt @@ -0,0 +1,24 @@ +--TEST-- +braces variable replacement test (heredoc) +--FILE-- + +--EXPECT-- +This is heredoc test #1. +This is heredoc test #2. diff --git a/tests/zend/heredoc_nowdoc/heredoc_005.phpt b/tests/zend/heredoc_nowdoc/heredoc_005.phpt new file mode 100644 index 00000000..f7fac7ca --- /dev/null +++ b/tests/zend/heredoc_nowdoc/heredoc_005.phpt @@ -0,0 +1,28 @@ +--TEST-- +unbraced complex variable replacement test (heredoc) +--FILE-- + 3, ); + $d = new d; + + print <<d. + + ENDOFHEREDOC; + + $x = <<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. diff --git a/tests/zend/heredoc_nowdoc/nowdoc.inc b/tests/zend/heredoc_nowdoc/nowdoc.inc new file mode 100644 index 00000000..d2aa5c4a --- /dev/null +++ b/tests/zend/heredoc_nowdoc/nowdoc.inc @@ -0,0 +1,10 @@ + 3, ); +class d { public $d = 4; }; +$d = new d; + +?>