Skip to content

Commit 607be65

Browse files
committed
Fixed bug #81342
Allow arbitrary whitespace, not just horizontal spaces.
1 parent e9b2852 commit 607be65

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-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 8.1.0beta3
44

5+
- Core:
6+
. Fixed bug #81342 (New ampersand token parsing depends on new line after it).
7+
(Nikita)
8+
59
- Date:
610
. Fixed bug #79580 (date_create_from_format misses leap year). (Derick)
711
. Fixed bug #80963 (DateTimeZone::getTransitions() truncated). (Derick)

Zend/zend_language_scanner.l

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1858,7 +1858,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
18581858
RETURN_TOKEN(T_SR);
18591859
}
18601860

1861-
<ST_IN_SCRIPTING>"&"{TABS_AND_SPACES}("$"|"...") {
1861+
<ST_IN_SCRIPTING>"&"[ \t\r\n]*("$"|"...") {
18621862
yyless(1);
18631863
RETURN_TOKEN(T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG);
18641864
}

ext/tokenizer/tests/bug81342.phpt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
Bug #81342: New ampersand token parsing depends on new line after it
3+
--FILE--
4+
<?php
5+
6+
$tokens = PhpToken::tokenize('<?php $x & $x; $x &
7+
$baz;
8+
');
9+
foreach ($tokens as $token) {
10+
echo $token->getTokenName(), "\n";
11+
}
12+
13+
?>
14+
--EXPECT--
15+
T_OPEN_TAG
16+
T_VARIABLE
17+
T_WHITESPACE
18+
T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG
19+
T_WHITESPACE
20+
T_VARIABLE
21+
;
22+
T_WHITESPACE
23+
T_VARIABLE
24+
T_WHITESPACE
25+
T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG
26+
T_WHITESPACE
27+
T_VARIABLE
28+
;
29+
T_WHITESPACE

0 commit comments

Comments
 (0)