summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/zend_language_scanner.l3
-rw-r--r--ext/tokenizer/tests/php_tag_only.phpt2
-rw-r--r--ext/tokenizer/tests/php_tag_only_2.phpt23
3 files changed, 27 insertions, 1 deletions
diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l
index dcf11bef5e..27fb296d58 100644
--- a/Zend/zend_language_scanner.l
+++ b/Zend/zend_language_scanner.l
@@ -2057,7 +2057,8 @@ inline_char_handler:
if (CG(short_tags) /* <? */
|| (*(YYCURSOR + 1) == '=') /* <?= */
|| (!strncasecmp((char*)YYCURSOR + 1, "php", 3) && /* <?php[ \t\r\n] */
- (YYCURSOR[4] == ' ' || YYCURSOR[4] == '\t' ||
+ (YYCURSOR + 4 == YYLIMIT ||
+ YYCURSOR[4] == ' ' || YYCURSOR[4] == '\t' ||
YYCURSOR[4] == '\n' || YYCURSOR[4] == '\r'))
) {
YYCURSOR--;
diff --git a/ext/tokenizer/tests/php_tag_only.phpt b/ext/tokenizer/tests/php_tag_only.phpt
index aec11f9e16..3d51e0cea5 100644
--- a/ext/tokenizer/tests/php_tag_only.phpt
+++ b/ext/tokenizer/tests/php_tag_only.phpt
@@ -2,6 +2,8 @@
Tokenization of only the <?php tag
--SKIPIF--
<?php if (!extension_loaded("tokenizer")) print "skip tokenizer extension not enabled"; ?>
+--INI--
+short_open_tag=1
--FILE--
<?php
diff --git a/ext/tokenizer/tests/php_tag_only_2.phpt b/ext/tokenizer/tests/php_tag_only_2.phpt
new file mode 100644
index 0000000000..60e4004179
--- /dev/null
+++ b/ext/tokenizer/tests/php_tag_only_2.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Tokenization of only the <?php tag
+--SKIPIF--
+<?php if (!extension_loaded("tokenizer")) print "skip tokenizer extension not enabled"; ?>
+--INI--
+short_open_tag=0
+--FILE--
+<?php
+
+foreach (token_get_all("<?php") as $token) {
+ echo token_name($token[0]), "\n";
+}
+echo "\n";
+foreach (token_get_all("Foobar<?php") as $token) {
+ echo token_name($token[0]), "\n";
+}
+
+?>
+--EXPECT--
+T_OPEN_TAG
+
+T_INLINE_HTML
+T_OPEN_TAG