Skip to content

Commit b078ae6

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
2 parents 01b3cc4 + 239e2dd commit b078ae6

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Zend/zend_compile.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1603,13 +1603,17 @@ ZEND_API void zend_activate_auto_globals(void) /* {{{ */
16031603
int ZEND_FASTCALL zendlex(zend_parser_stack_elem *elem) /* {{{ */
16041604
{
16051605
zval zv;
1606+
int ret;
16061607

16071608
if (CG(increment_lineno)) {
16081609
CG(zend_lineno)++;
16091610
CG(increment_lineno) = 0;
16101611
}
16111612

1612-
return lex_scan(&zv, elem);
1613+
ret = lex_scan(&zv, elem);
1614+
ZEND_ASSERT(!EG(exception) || ret == T_ERROR);
1615+
return ret;
1616+
16131617
}
16141618
/* }}} */
16151619

Zend/zend_language_scanner.l

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2405,6 +2405,9 @@ skip_escape_conversion:
24052405
if (!IS_LABEL_SUCCESSOR(YYCURSOR[heredoc_label->length])) {
24062406
if (spacing == (HEREDOC_USING_SPACES | HEREDOC_USING_TABS)) {
24072407
zend_throw_exception(zend_ce_parse_error, "Invalid indentation - tabs and spaces cannot be mixed", 0);
2408+
if (PARSER_MODE()) {
2409+
RETURN_TOKEN(T_ERROR);
2410+
}
24082411
}
24092412
24102413
YYCURSOR = saved_cursor;
@@ -2421,6 +2424,7 @@ skip_escape_conversion:
24212424
zend_lex_state current_state;
24222425
int heredoc_nesting_level = 1;
24232426
int first_token = 0;
2427+
int error = 0;
24242428
24252429
zend_save_lexical_state(&current_state);
24262430
@@ -2468,6 +2472,7 @@ skip_escape_conversion:
24682472
|| first_token == T_CURLY_OPEN
24692473
) && SCNG(heredoc_indentation)) {
24702474
zend_throw_exception_ex(zend_ce_parse_error, 0, "Invalid body indentation level (expecting an indentation level of at least %d)", SCNG(heredoc_indentation));
2475+
error = 1;
24712476
}
24722477
24732478
heredoc_label->indentation = SCNG(heredoc_indentation);
@@ -2476,6 +2481,10 @@ skip_escape_conversion:
24762481
zend_restore_lexical_state(&current_state);
24772482
SCNG(heredoc_scan_ahead) = 0;
24782483
CG(increment_lineno) = 0;
2484+
2485+
if (PARSER_MODE() && error) {
2486+
RETURN_TOKEN(T_ERROR);
2487+
}
24792488
}
24802489
24812490
RETURN_TOKEN(T_START_HEREDOC);
@@ -2665,6 +2674,9 @@ double_quotes_scan_done:
26652674
26662675
if (spacing == (HEREDOC_USING_SPACES | HEREDOC_USING_TABS)) {
26672676
zend_throw_exception(zend_ce_parse_error, "Invalid indentation - tabs and spaces cannot be mixed", 0);
2677+
if (PARSER_MODE()) {
2678+
RETURN_TOKEN(T_ERROR);
2679+
}
26682680
}
26692681
26702682
/* newline before label will be subtracted from returned text, but
@@ -2786,6 +2798,9 @@ heredoc_scan_done:
27862798
27872799
if (spacing == (HEREDOC_USING_SPACES | HEREDOC_USING_TABS)) {
27882800
zend_throw_exception(zend_ce_parse_error, "Invalid indentation - tabs and spaces cannot be mixed", 0);
2801+
if (PARSER_MODE()) {
2802+
RETURN_TOKEN(T_ERROR);
2803+
}
27892804
}
27902805
27912806
/* newline before label will be subtracted from returned text, but

0 commit comments

Comments
 (0)