summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2011-02-28 15:18:27 +0000
committerIlia Alshanetsky <iliaa@php.net>2011-02-28 15:18:27 +0000
commit1d984a7ffd60a36875e04cbc2d4bbf1d4b1524c8 (patch)
treef3a06bd221148b153082ed09b271cd31310807a9 /ext
parente65d361fde2eb71d4070b9c881f5f02bb7f5eeed (diff)
downloadphp-git-1d984a7ffd60a36875e04cbc2d4bbf1d4b1524c8.tar.gz
Fixed bug #54089 (token_get_all() does not stop after __halt_compiler).
Diffstat (limited to 'ext')
-rw-r--r--ext/tokenizer/tests/bug54089.phpt40
-rw-r--r--ext/tokenizer/tests/token_get_all_variation16.phpt57
-rw-r--r--ext/tokenizer/tokenizer.c4
3 files changed, 54 insertions, 47 deletions
diff --git a/ext/tokenizer/tests/bug54089.phpt b/ext/tokenizer/tests/bug54089.phpt
new file mode 100644
index 0000000000..e1f6d79e9c
--- /dev/null
+++ b/ext/tokenizer/tests/bug54089.phpt
@@ -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"
diff --git a/ext/tokenizer/tests/token_get_all_variation16.phpt b/ext/tokenizer/tests/token_get_all_variation16.phpt
index 2422d30266..4ae694e741 100644
--- a/ext/tokenizer/tests/token_get_all_variation16.phpt
+++ b/ext/tokenizer/tests/token_get_all_variation16.phpt
@@ -55,7 +55,7 @@ echo "Done"
?>
--EXPECTF--
*** Testing token_get_all() : with different function constructs ***
-array(142) {
+array(135) {
[0]=>
array(3) {
[0]=>
@@ -114,11 +114,11 @@ array(142) {
[9]=>
array(3) {
[0]=>
- int(262)
+ int(%d)
[1]=>
string(7) "include"
[2]=>
- int(%d)
+ int(3)
}
[10]=>
string(1) "("
@@ -129,7 +129,7 @@ array(142) {
[1]=>
string(13) ""addfile.php""
[2]=>
- int(%d)
+ int(3)
}
[12]=>
string(1) ")"
@@ -143,12 +143,12 @@ array(142) {
string(1) "
"
[2]=>
- int(%d)
+ int(3)
}
[15]=>
array(3) {
[0]=>
- int(259)
+ int(%d)
[1]=>
string(7) "require"
[2]=>
@@ -590,7 +590,7 @@ array(142) {
[79]=>
array(3) {
[0]=>
- int(267)
+ int(%d)
[1]=>
string(3) ">>="
[2]=>
@@ -659,7 +659,7 @@ array(142) {
[88]=>
array(3) {
[0]=>
- int(285)
+ int(%d)
[1]=>
string(2) "<="
[2]=>
@@ -738,7 +738,7 @@ array(142) {
[98]=>
array(3) {
[0]=>
- int(266)
+ int(%d)
[1]=>
string(5) "print"
[2]=>
@@ -889,7 +889,7 @@ array(142) {
[123]=>
array(3) {
[0]=>
- int(279)
+ int(%d)
[1]=>
string(2) "&&"
[2]=>
@@ -960,42 +960,5 @@ array(142) {
[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
diff --git a/ext/tokenizer/tokenizer.c b/ext/tokenizer/tokenizer.c
index bab549bad7..add3168f7c 100644
--- a/ext/tokenizer/tokenizer.c
+++ b/ext/tokenizer/tokenizer.c
@@ -151,6 +151,10 @@ static void tokenize(zval *return_value TSRMLS_DC)
ZVAL_NULL(&token);
token_line = CG(zend_lineno);
+
+ if (token_type == T_HALT_COMPILER) {
+ break;
+ }
}
}