Fix #78441: Parse error due to heredoc identifier followed by digit

Since digits are allowed for identifiers, we have to cater to them as
well.
This commit is contained in:
Christoph M. Becker 2019-08-21 22:51:51 +02:00
parent 08aafbe93e
commit 310708845f
5 changed files with 384 additions and 356 deletions

2
NEWS
View File

@ -6,6 +6,8 @@ PHP NEWS
. Fixed bug #78220 (Can't access OneDrive folder). (cmb, ab)
. Fixed bug #77922 (Double release of doc comment on inherited shadow
property). (Nikita)
. Fixed bug #78441 (Parse error due to heredoc identifier followed by digit).
(cmb)
- Intl:
. Ensure IDNA2003 rules are used with idn_to_ascii() and idn_to_utf8()

View File

@ -0,0 +1,24 @@
--TEST--
Bug #78441 (Parse error due to heredoc identifier followed by digit)
--FILE--
<?php
echo <<<FOO
FOO4
FOO, PHP_EOL;
echo <<<FOO
bar
FOO4
FOO, PHP_EOL;
echo <<<'FOO'
bar
FOO4
FOO, PHP_EOL;
?>
--EXPECT--
FOO4
bar
FOO4
bar
FOO4

File diff suppressed because it is too large Load Diff

View File

@ -115,6 +115,7 @@ do { \
#define GET_DOUBLE_QUOTES_SCANNED_LENGTH() SCNG(scanned_string_len)
#define IS_LABEL_START(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z') || (c) == '_' || (c) >= 0x80)
#define IS_LABEL_SUCCESSOR(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z') || ((c) >= '0' && (c) <= '9') || (c) == '_' || (c) >= 0x80)
#define ZEND_IS_OCT(c) ((c)>='0' && (c)<='7')
#define ZEND_IS_HEX(c) (((c)>='0' && (c)<='9') || ((c)>='a' && (c)<='f') || ((c)>='A' && (c)<='F'))
@ -2319,7 +2320,7 @@ skip_escape_conversion:
/* Check for ending label on the next line */
if (heredoc_label->length < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, s, heredoc_label->length)) {
if (!IS_LABEL_START(YYCURSOR[heredoc_label->length])) {
if (!IS_LABEL_SUCCESSOR(YYCURSOR[heredoc_label->length])) {
if (spacing == (HEREDOC_USING_SPACES | HEREDOC_USING_TABS)) {
zend_throw_exception(zend_ce_parse_error, "Invalid indentation - tabs and spaces cannot be mixed", 0);
}
@ -2576,7 +2577,7 @@ double_quotes_scan_done:
/* Check for ending label on the next line */
if (IS_LABEL_START(*YYCURSOR) && heredoc_label->length < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, heredoc_label->label, heredoc_label->length)) {
if (IS_LABEL_START(YYCURSOR[heredoc_label->length])) {
if (IS_LABEL_SUCCESSOR(YYCURSOR[heredoc_label->length])) {
continue;
}
@ -2697,7 +2698,7 @@ heredoc_scan_done:
/* Check for ending label on the next line */
if (IS_LABEL_START(*YYCURSOR) && heredoc_label->length < YYLIMIT - YYCURSOR && !memcmp(YYCURSOR, heredoc_label->label, heredoc_label->length)) {
if (IS_LABEL_START(YYCURSOR[heredoc_label->length])) {
if (IS_LABEL_SUCCESSOR(YYCURSOR[heredoc_label->length])) {
continue;
}

View File

@ -1,4 +1,4 @@
/* Generated by re2c 1.0.1 */
/* Generated by re2c 1.1.1 */
#line 3 "Zend/zend_language_scanner_defs.h"
enum YYCONDTYPE {