Skip to content

Commit 19e7e4b

Browse files
committed
Fixed bug #78604
<?php followed by EOF is valid since PHP 7.4.
1 parent 1806ce9 commit 19e7e4b

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 7.4.0RC3
44

5+
- Core:
6+
. Fixed bug #78604 (token_get_all() does not properly tokenize FOO<?php with
7+
short_open_tag=0). (Nikita)
8+
59
- FFI:
610
. Fixed bug #78543 (is_callable() on FFI\CData throws Exception). (cmb)
711

Zend/zend_language_scanner.l

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2057,7 +2057,8 @@ inline_char_handler:
20572057
if (CG(short_tags) /* <? */
20582058
|| (*(YYCURSOR + 1) == '=') /* <?= */
20592059
|| (!strncasecmp((char*)YYCURSOR + 1, "php", 3) && /* <?php[ \t\r\n] */
2060-
(YYCURSOR[4] == ' ' || YYCURSOR[4] == '\t' ||
2060+
(YYCURSOR + 4 == YYLIMIT ||
2061+
YYCURSOR[4] == ' ' || YYCURSOR[4] == '\t' ||
20612062
YYCURSOR[4] == '\n' || YYCURSOR[4] == '\r'))
20622063
) {
20632064
YYCURSOR--;

ext/tokenizer/tests/php_tag_only.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Tokenization of only the <?php tag
33
--SKIPIF--
44
<?php if (!extension_loaded("tokenizer")) print "skip tokenizer extension not enabled"; ?>
5+
--INI--
6+
short_open_tag=1
57
--FILE--
68
<?php
79

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Tokenization of only the <?php tag
3+
--SKIPIF--
4+
<?php if (!extension_loaded("tokenizer")) print "skip tokenizer extension not enabled"; ?>
5+
--INI--
6+
short_open_tag=0
7+
--FILE--
8+
<?php
9+
10+
foreach (token_get_all("<?php") as $token) {
11+
echo token_name($token[0]), "\n";
12+
}
13+
echo "\n";
14+
foreach (token_get_all("Foobar<?php") as $token) {
15+
echo token_name($token[0]), "\n";
16+
}
17+
18+
?>
19+
--EXPECT--
20+
T_OPEN_TAG
21+
22+
T_INLINE_HTML
23+
T_OPEN_TAG

0 commit comments

Comments
 (0)