Skip to content

Commit 0d568b9

Browse files
committed
Don't split T_INLINE_HTML at partial PHP tag
If <?php occurs without required trailing whitespace, we should keep it as part of a single T_INLINE_HTML region.
1 parent 79b5b1a commit 0d568b9

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

Zend/zend_language_scanner.l

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,8 +2059,12 @@ inline_char_handler:
20592059
}
20602060

20612061
if (*YYCURSOR == '?') {
2062-
if (CG(short_tags) || !strncasecmp((char*)YYCURSOR + 1, "php", 3) || (*(YYCURSOR + 1) == '=')) { /* Assume [ \t\n\r] follows "php" */
2063-
2062+
if (CG(short_tags) /* <? */
2063+
|| (*(YYCURSOR + 1) == '=') /* <?= */
2064+
|| (!strncasecmp((char*)YYCURSOR + 1, "php", 3) && /* <?php[ \t\r\n] */
2065+
(YYCURSOR[4] == ' ' || YYCURSOR[4] == '\t' ||
2066+
YYCURSOR[4] == '\n' || YYCURSOR[4] == '\r'))
2067+
) {
20642068
YYCURSOR--;
20652069
break;
20662070
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Inline HTML should not be split at partial PHP tags
3+
--INI--
4+
short_open_tag=0
5+
--FILE--
6+
<?php
7+
8+
var_dump(token_get_all(<<<'PHP'
9+
Foo<?phpBar
10+
PHP));
11+
12+
?>
13+
--EXPECTF--
14+
array(1) {
15+
[0]=>
16+
array(3) {
17+
[0]=>
18+
int(%d)
19+
[1]=>
20+
string(11) "Foo<?phpBar"
21+
[2]=>
22+
int(1)
23+
}
24+
}

0 commit comments

Comments
 (0)