diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2019-08-21 22:55:25 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2019-08-21 22:55:25 +0200 |
commit | c53064fbff669f9e8122e22450c9c76d1303ad08 (patch) | |
tree | 10261efed79f2406ef3071f8dcd38b5953dfa7b3 | |
parent | 7d4e3dc32d5bcf386f53607b3190e9a856844ad1 (diff) | |
parent | 1eb75f2937a85a9707466a8d68340bcaf55a3c15 (diff) | |
download | php-git-c53064fbff669f9e8122e22450c9c76d1303ad08.tar.gz |
Merge branch 'PHP-7.4'
* PHP-7.4:
Fix #78441: Parse error due to heredoc identifier followed by digit
-rw-r--r-- | Zend/tests/grammar/bug78441.phpt | 24 | ||||
-rw-r--r-- | Zend/zend_language_scanner.l | 7 |
2 files changed, 28 insertions, 3 deletions
diff --git a/Zend/tests/grammar/bug78441.phpt b/Zend/tests/grammar/bug78441.phpt new file mode 100644 index 0000000000..af05ecf1d8 --- /dev/null +++ b/Zend/tests/grammar/bug78441.phpt @@ -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 diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index bbb6602372..ef5230b409 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -113,6 +113,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')) @@ -2419,7 +2420,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); } @@ -2676,7 +2677,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; } @@ -2797,7 +2798,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; } |