iliaa Mon, 28 Feb 2011 15:18:27 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=308761
Log:
Fixed bug #54089 (token_get_all() does not stop after __halt_compiler).
Bug: http://bugs.php.net/54089 (Open) token_get_all with regards to
__halt_compiler is not binary safe
Changed paths:
U php/php-src/branches/PHP_5_3/NEWS
A php/php-src/branches/PHP_5_3/ext/tokenizer/tests/bug54089.phpt
U
php/php-src/branches/PHP_5_3/ext/tokenizer/tests/token_get_all_variation16.phpt
U php/php-src/branches/PHP_5_3/ext/tokenizer/tokenizer.c
A php/php-src/trunk/ext/tokenizer/tests/bug54089.phpt
U php/php-src/trunk/ext/tokenizer/tests/token_get_all_variation16.phpt
U php/php-src/trunk/ext/tokenizer/tokenizer.c
Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS 2011-02-28 14:16:00 UTC (rev 308760)
+++ php/php-src/branches/PHP_5_3/NEWS 2011-02-28 15:18:27 UTC (rev 308761)
@@ -16,6 +16,11 @@
- SPL extension:
. Fixed memory leak in DirectoryIterator::getExtension() and
SplFileInfo::getExtension(). (Felipe)
+
+- Tokenizer Extension
+ . Fixed bug #54089 (token_get_all() does not stop after __halt_compiler).
+ (Ilia)
+
17 Feb 2011, PHP 5.3.6RC1
- Upgraded bundled Sqlite3 to version 3.7.4. (Ilia)
- Upgraded bundled PCRE to version 8.11. (Ilia)
Added: php/php-src/branches/PHP_5_3/ext/tokenizer/tests/bug54089.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/tokenizer/tests/bug54089.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/tokenizer/tests/bug54089.phpt 2011-02-28 15:18:27 UTC (rev 308761)
@@ -0,0 +1,40 @@
+--TEST--
+Bug #54089 (token_get_all() does not stop after __halt_compiler)
+--SKIPIF--
+<?php if (!extension_loaded("tokenizer")) print "skip"; ?>
+--FILE--
+<?php
+$code = "<?php __halt_compiler();\x01?>\x02";
+$tokens = token_get_all($code);
+
+var_dump($tokens);
+
+$code = '';
+foreach ($tokens as $t)
+{
+ $code .= isset($t[1]) ? $t[1] : $t;
+}
+var_dump($code);
+?>
+--EXPECTF--
+array(2) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(%d)
+ [1]=>
+ string(6) "<?php "
+ [2]=>
+ int(1)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(%d)
+ [1]=>
+ string(15) "__halt_compiler"
+ [2]=>
+ int(1)
+ }
+}
+string(21) "<?php __halt_compiler"
Modified: php/php-src/branches/PHP_5_3/ext/tokenizer/tests/token_get_all_variation16.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/tokenizer/tests/token_get_all_variation16.phpt 2011-02-28 14:16:00 UTC (rev 308760)
+++ php/php-src/branches/PHP_5_3/ext/tokenizer/tests/token_get_all_variation16.phpt 2011-02-28 15:18:27 UTC (rev 308761)
@@ -55,11 +55,11 @@
?>
--EXPECTF--
*** Testing token_get_all() : with different function constructs ***
-array(142) {
+array(135) {
[0]=>
array(3) {
[0]=>
- int(368)
+ int(%d)
[1]=>
string(6) "<?php
"
@@ -69,7 +69,7 @@
[1]=>
array(3) {
[0]=>
- int(324)
+ int(%d)
[1]=>
string(7) "declare"
[2]=>
@@ -80,7 +80,7 @@
[3]=>
array(3) {
[0]=>
- int(307)
+ int(%d)
[1]=>
string(5) "VALUE"
[2]=>
@@ -91,7 +91,7 @@
[5]=>
array(3) {
[0]=>
- int(305)
+ int(%d)
[1]=>
string(3) "100"
[2]=>
@@ -104,7 +104,7 @@
[8]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) "
"
@@ -114,7 +114,7 @@
[9]=>
array(3) {
[0]=>
- int(262)
+ int(%d)
[1]=>
string(7) "include"
[2]=>
@@ -125,7 +125,7 @@
[11]=>
array(3) {
[0]=>
- int(315)
+ int(%d)
[1]=>
string(13) ""addfile.php""
[2]=>
@@ -138,7 +138,7 @@
[14]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) "
"
@@ -148,7 +148,7 @@
[15]=>
array(3) {
[0]=>
- int(259)
+ int(%d)
[1]=>
string(7) "require"
[2]=>
@@ -159,7 +159,7 @@
[17]=>
array(3) {
[0]=>
- int(315)
+ int(%d)
[1]=>
string(13) ""sumfile.php""
[2]=>
@@ -172,7 +172,7 @@
[20]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(2) "
@@ -183,7 +183,7 @@
[21]=>
array(3) {
[0]=>
- int(334)
+ int(%d)
[1]=>
string(8) "function"
[2]=>
@@ -192,7 +192,7 @@
[22]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) " "
[2]=>
@@ -201,7 +201,7 @@
[23]=>
array(3) {
[0]=>
- int(307)
+ int(%d)
[1]=>
string(10) "myFunction"
[2]=>
@@ -212,7 +212,7 @@
[25]=>
array(3) {
[0]=>
- int(309)
+ int(%d)
[1]=>
string(2) "$a"
[2]=>
@@ -223,7 +223,7 @@
[27]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) "
"
@@ -235,7 +235,7 @@
[29]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(3) "
"
@@ -245,7 +245,7 @@
[30]=>
array(3) {
[0]=>
- int(301)
+ int(%d)
[1]=>
string(2) "if"
[2]=>
@@ -256,7 +256,7 @@
[32]=>
array(3) {
[0]=>
- int(309)
+ int(%d)
[1]=>
string(2) "$a"
[2]=>
@@ -265,7 +265,7 @@
[33]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) " "
[2]=>
@@ -276,7 +276,7 @@
[35]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) " "
[2]=>
@@ -285,7 +285,7 @@
[36]=>
array(3) {
[0]=>
- int(305)
+ int(%d)
[1]=>
string(1) "2"
[2]=>
@@ -296,7 +296,7 @@
[38]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(5) "
"
@@ -306,7 +306,7 @@
[39]=>
array(3) {
[0]=>
- int(336)
+ int(%d)
[1]=>
string(6) "return"
[2]=>
@@ -315,7 +315,7 @@
[40]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) " "
[2]=>
@@ -324,7 +324,7 @@
[41]=>
array(3) {
[0]=>
- int(305)
+ int(%d)
[1]=>
string(1) "1"
[2]=>
@@ -335,7 +335,7 @@
[43]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(3) "
"
@@ -345,7 +345,7 @@
[44]=>
array(3) {
[0]=>
- int(303)
+ int(%d)
[1]=>
string(4) "else"
[2]=>
@@ -354,7 +354,7 @@
[45]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(5) "
"
@@ -364,7 +364,7 @@
[46]=>
array(3) {
[0]=>
- int(300)
+ int(%d)
[1]=>
string(4) "exit"
[2]=>
@@ -375,7 +375,7 @@
[48]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) "
"
@@ -387,7 +387,7 @@
[50]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(2) "
@@ -398,7 +398,7 @@
[51]=>
array(3) {
[0]=>
- int(309)
+ int(%d)
[1]=>
string(2) "$a"
[2]=>
@@ -407,7 +407,7 @@
[52]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) " "
[2]=>
@@ -418,7 +418,7 @@
[54]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) " "
[2]=>
@@ -427,7 +427,7 @@
[55]=>
array(3) {
[0]=>
- int(307)
+ int(%d)
[1]=>
string(5) "VALUE"
[2]=>
@@ -438,7 +438,7 @@
[57]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) "
"
@@ -448,7 +448,7 @@
[58]=>
array(3) {
[0]=>
- int(309)
+ int(%d)
[1]=>
string(2) "$b"
[2]=>
@@ -457,7 +457,7 @@
[59]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) " "
[2]=>
@@ -468,7 +468,7 @@
[61]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) " "
[2]=>
@@ -477,7 +477,7 @@
[62]=>
array(3) {
[0]=>
- int(305)
+ int(%d)
[1]=>
string(2) "20"
[2]=>
@@ -488,7 +488,7 @@
[64]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) "
"
@@ -498,7 +498,7 @@
[65]=>
array(3) {
[0]=>
- int(309)
+ int(%d)
[1]=>
string(2) "$c"
[2]=>
@@ -507,7 +507,7 @@
[66]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) " "
[2]=>
@@ -518,7 +518,7 @@
[68]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) " "
[2]=>
@@ -527,7 +527,7 @@
[69]=>
array(3) {
[0]=>
- int(360)
+ int(%d)
[1]=>
string(5) "array"
[2]=>
@@ -538,7 +538,7 @@
[71]=>
array(3) {
[0]=>
- int(305)
+ int(%d)
[1]=>
string(1) "1"
[2]=>
@@ -549,7 +549,7 @@
[73]=>
array(3) {
[0]=>
- int(305)
+ int(%d)
[1]=>
string(1) "2"
[2]=>
@@ -562,7 +562,7 @@
[76]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) "
"
@@ -572,7 +572,7 @@
[77]=>
array(3) {
[0]=>
- int(309)
+ int(%d)
[1]=>
string(2) "$b"
[2]=>
@@ -581,7 +581,7 @@
[78]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) " "
[2]=>
@@ -590,7 +590,7 @@
[79]=>
array(3) {
[0]=>
- int(267)
+ int(%d)
[1]=>
string(3) ">>="
[2]=>
@@ -599,7 +599,7 @@
[80]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) " "
[2]=>
@@ -608,7 +608,7 @@
[81]=>
array(3) {
[0]=>
- int(305)
+ int(%d)
[1]=>
string(1) "2"
[2]=>
@@ -619,7 +619,7 @@
[83]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(2) "
@@ -630,7 +630,7 @@
[84]=>
array(3) {
[0]=>
- int(301)
+ int(%d)
[1]=>
string(2) "if"
[2]=>
@@ -641,7 +641,7 @@
[86]=>
array(3) {
[0]=>
- int(309)
+ int(%d)
[1]=>
string(2) "$b"
[2]=>
@@ -650,7 +650,7 @@
[87]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) " "
[2]=>
@@ -659,7 +659,7 @@
[88]=>
array(3) {
[0]=>
- int(285)
+ int(%d)
[1]=>
string(2) "<="
[2]=>
@@ -668,7 +668,7 @@
[89]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) " "
[2]=>
@@ -677,7 +677,7 @@
[90]=>
array(3) {
[0]=>
- int(305)
+ int(%d)
[1]=>
string(1) "0"
[2]=>
@@ -688,7 +688,7 @@
[92]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(3) "
"
@@ -698,7 +698,7 @@
[93]=>
array(3) {
[0]=>
- int(300)
+ int(%d)
[1]=>
string(3) "die"
[2]=>
@@ -709,7 +709,7 @@
[95]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) "
"
@@ -719,7 +719,7 @@
[96]=>
array(3) {
[0]=>
- int(303)
+ int(%d)
[1]=>
string(4) "else"
[2]=>
@@ -728,7 +728,7 @@
[97]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(3) "
"
@@ -738,7 +738,7 @@
[98]=>
array(3) {
[0]=>
- int(266)
+ int(%d)
[1]=>
string(5) "print"
[2]=>
@@ -749,7 +749,7 @@
[100]=>
array(3) {
[0]=>
- int(309)
+ int(%d)
[1]=>
string(2) "$b"
[2]=>
@@ -762,7 +762,7 @@
[103]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(2) "
@@ -773,7 +773,7 @@
[104]=>
array(3) {
[0]=>
- int(359)
+ int(%d)
[1]=>
string(4) "list"
[2]=>
@@ -784,7 +784,7 @@
[106]=>
array(3) {
[0]=>
- int(309)
+ int(%d)
[1]=>
string(7) "$value1"
[2]=>
@@ -795,7 +795,7 @@
[108]=>
array(3) {
[0]=>
- int(309)
+ int(%d)
[1]=>
string(7) "$value2"
[2]=>
@@ -806,7 +806,7 @@
[110]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) " "
[2]=>
@@ -817,7 +817,7 @@
[112]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) " "
[2]=>
@@ -826,7 +826,7 @@
[113]=>
array(3) {
[0]=>
- int(309)
+ int(%d)
[1]=>
string(2) "$c"
[2]=>
@@ -837,7 +837,7 @@
[115]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) "
"
@@ -847,7 +847,7 @@
[116]=>
array(3) {
[0]=>
- int(301)
+ int(%d)
[1]=>
string(2) "if"
[2]=>
@@ -858,7 +858,7 @@
[118]=>
array(3) {
[0]=>
- int(351)
+ int(%d)
[1]=>
string(5) "empty"
[2]=>
@@ -869,7 +869,7 @@
[120]=>
array(3) {
[0]=>
- int(309)
+ int(%d)
[1]=>
string(7) "$value1"
[2]=>
@@ -880,7 +880,7 @@
[122]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) " "
[2]=>
@@ -889,7 +889,7 @@
[123]=>
array(3) {
[0]=>
- int(279)
+ int(%d)
[1]=>
string(2) "&&"
[2]=>
@@ -898,7 +898,7 @@
[124]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) " "
[2]=>
@@ -909,7 +909,7 @@
[126]=>
array(3) {
[0]=>
- int(350)
+ int(%d)
[1]=>
string(5) "isset"
[2]=>
@@ -920,7 +920,7 @@
[128]=>
array(3) {
[0]=>
- int(309)
+ int(%d)
[1]=>
string(7) "$value1"
[2]=>
@@ -933,7 +933,7 @@
[131]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(1) " "
[2]=>
@@ -944,7 +944,7 @@
[133]=>
array(3) {
[0]=>
- int(371)
+ int(%d)
[1]=>
string(3) "
"
@@ -954,48 +954,11 @@
[134]=>
array(3) {
[0]=>
- int(352)
+ int(%d)
[1]=>
string(15) "__halt_compiler"
[2]=>
int(26)
}
- [135]=>
- string(1) "("
- [136]=>
- string(1) ")"
- [137]=>
- string(1) ";"
- [138]=>
- array(3) {
- [0]=>
- int(371)
- [1]=>
- string(1) "
-"
- [2]=>
- int(26)
- }
- [139]=>
- string(1) "}"
- [140]=>
- array(3) {
- [0]=>
- int(371)
- [1]=>
- string(1) "
-"
- [2]=>
- int(27)
- }
- [141]=>
- array(3) {
- [0]=>
- int(370)
- [1]=>
- string(2) "?>"
- [2]=>
- int(28)
- }
}
Done
Modified: php/php-src/branches/PHP_5_3/ext/tokenizer/tokenizer.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/tokenizer/tokenizer.c 2011-02-28 14:16:00 UTC (rev 308760)
+++ php/php-src/branches/PHP_5_3/ext/tokenizer/tokenizer.c 2011-02-28 15:18:27 UTC (rev 308761)
@@ -151,6 +151,10 @@
ZVAL_NULL(&token);
token_line = CG(zend_lineno);
+
+ if (token_type == T_HALT_COMPILER) {
+ break;
+ }
}
}
Added: php/php-src/trunk/ext/tokenizer/tests/bug54089.phpt
===================================================================
--- php/php-src/trunk/ext/tokenizer/tests/bug54089.phpt (rev 0)
+++ php/php-src/trunk/ext/tokenizer/tests/bug54089.phpt 2011-02-28 15:18:27 UTC (rev 308761)
@@ -0,0 +1,40 @@
+--TEST--
+Bug #54089 (token_get_all() does not stop after __halt_compiler)
+--SKIPIF--
+<?php if (!extension_loaded("tokenizer")) print "skip"; ?>
+--FILE--
+<?php
+$code = "<?php __halt_compiler();\x01?>\x02";
+$tokens = token_get_all($code);
+
+var_dump($tokens);
+
+$code = '';
+foreach ($tokens as $t)
+{
+ $code .= isset($t[1]) ? $t[1] : $t;
+}
+var_dump($code);
+?>
+--EXPECTF--
+array(2) {
+ [0]=>
+ array(3) {
+ [0]=>
+ int(%d)
+ [1]=>
+ string(6) "<?php "
+ [2]=>
+ int(1)
+ }
+ [1]=>
+ array(3) {
+ [0]=>
+ int(%d)
+ [1]=>
+ string(15) "__halt_compiler"
+ [2]=>
+ int(1)
+ }
+}
+string(21) "<?php __halt_compiler"
Modified: php/php-src/trunk/ext/tokenizer/tests/token_get_all_variation16.phpt
===================================================================
--- php/php-src/trunk/ext/tokenizer/tests/token_get_all_variation16.phpt 2011-02-28 14:16:00 UTC (rev 308760)
+++ php/php-src/trunk/ext/tokenizer/tests/token_get_all_variation16.phpt 2011-02-28 15:18:27 UTC (rev 308761)
@@ -55,7 +55,7 @@
?>
--EXPECTF--
*** Testing token_get_all() : with different function constructs ***
-array(142) {
+array(135) {
[0]=>
array(3) {
[0]=>
@@ -114,11 +114,11 @@
[9]=>
array(3) {
[0]=>
- int(262)
+ int(%d)
[1]=>
string(7) "include"
[2]=>
- int(%d)
+ int(3)
}
[10]=>
string(1) "("
@@ -129,7 +129,7 @@
[1]=>
string(13) ""addfile.php""
[2]=>
- int(%d)
+ int(3)
}
[12]=>
string(1) ")"
@@ -143,12 +143,12 @@
string(1) "
"
[2]=>
- int(%d)
+ int(3)
}
[15]=>
array(3) {
[0]=>
- int(259)
+ int(%d)
[1]=>
string(7) "require"
[2]=>
@@ -590,7 +590,7 @@
[79]=>
array(3) {
[0]=>
- int(267)
+ int(%d)
[1]=>
string(3) ">>="
[2]=>
@@ -659,7 +659,7 @@
[88]=>
array(3) {
[0]=>
- int(285)
+ int(%d)
[1]=>
string(2) "<="
[2]=>
@@ -738,7 +738,7 @@
[98]=>
array(3) {
[0]=>
- int(266)
+ int(%d)
[1]=>
string(5) "print"
[2]=>
@@ -889,7 +889,7 @@
[123]=>
array(3) {
[0]=>
- int(279)
+ int(%d)
[1]=>
string(2) "&&"
[2]=>
@@ -960,42 +960,5 @@
[2]=>
int(26)
}
- [135]=>
- string(1) "("
- [136]=>
- string(1) ")"
- [137]=>
- string(1) ";"
- [138]=>
- array(3) {
- [0]=>
- int(%d)
- [1]=>
- string(1) "
-"
- [2]=>
- int(26)
- }
- [139]=>
- string(1) "}"
- [140]=>
- array(3) {
- [0]=>
- int(%d)
- [1]=>
- string(1) "
-"
- [2]=>
- int(27)
- }
- [141]=>
- array(3) {
- [0]=>
- int(%d)
- [1]=>
- string(2) "?>"
- [2]=>
- int(28)
- }
}
Done
Modified: php/php-src/trunk/ext/tokenizer/tokenizer.c
===================================================================
--- php/php-src/trunk/ext/tokenizer/tokenizer.c 2011-02-28 14:16:00 UTC (rev 308760)
+++ php/php-src/trunk/ext/tokenizer/tokenizer.c 2011-02-28 15:18:27 UTC (rev 308761)
@@ -151,6 +151,10 @@
ZVAL_NULL(&token);
token_line = CG(zend_lineno);
+
+ if (token_type == T_HALT_COMPILER) {
+ break;
+ }
}
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php