Skip to content

Commit

Permalink
Fixed bug #81342
Browse files Browse the repository at this point in the history
Allow arbitrary whitespace, not just horizontal spaces.
  • Loading branch information
nikic committed Aug 10, 2021
1 parent e9b2852 commit 607be65
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 8.1.0beta3

- Core:
. Fixed bug #81342 (New ampersand token parsing depends on new line after it).
(Nikita)

- Date:
. Fixed bug #79580 (date_create_from_format misses leap year). (Derick)
. Fixed bug #80963 (DateTimeZone::getTransitions() truncated). (Derick)
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_language_scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -1858,7 +1858,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
RETURN_TOKEN(T_SR);
}

<ST_IN_SCRIPTING>"&"{TABS_AND_SPACES}("$"|"...") {
<ST_IN_SCRIPTING>"&"[ \t\r\n]*("$"|"...") {
yyless(1);
RETURN_TOKEN(T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG);
}
Expand Down
29 changes: 29 additions & 0 deletions ext/tokenizer/tests/bug81342.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
--TEST--
Bug #81342: New ampersand token parsing depends on new line after it
--FILE--
<?php

$tokens = PhpToken::tokenize('<?php $x & $x; $x &
$baz;
');
foreach ($tokens as $token) {
echo $token->getTokenName(), "\n";
}

?>
--EXPECT--
T_OPEN_TAG
T_VARIABLE
T_WHITESPACE
T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG
T_WHITESPACE
T_VARIABLE
;
T_WHITESPACE
T_VARIABLE
T_WHITESPACE
T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG
T_WHITESPACE
T_VARIABLE
;
T_WHITESPACE

0 comments on commit 607be65

Please sign in to comment.