]> granicus.if.org Git - php/commitdiff
Make "unterminated comment" into a parse error
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 30 Oct 2019 10:00:27 +0000 (11:00 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 30 Oct 2019 10:00:27 +0000 (11:00 +0100)
Zend/tests/unterminated_comment.phpt [new file with mode: 0644]
Zend/tests/warning_during_heredoc_scan_ahead.phpt [deleted file]
Zend/zend_language_scanner.l

diff --git a/Zend/tests/unterminated_comment.phpt b/Zend/tests/unterminated_comment.phpt
new file mode 100644 (file)
index 0000000..8a0fb34
--- /dev/null
@@ -0,0 +1,8 @@
+--TEST--
+Unterminated comment
+--FILE--
+<?php
+/* Foo
+Bar
+--EXPECTF--
+Parse error: Unterminated comment starting line 2 in %s on line %d
diff --git a/Zend/tests/warning_during_heredoc_scan_ahead.phpt b/Zend/tests/warning_during_heredoc_scan_ahead.phpt
deleted file mode 100644 (file)
index 125c392..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
---TEST--
-No warnings should be thrown during heredoc scan-ahead
---FILE--
-<?php
-
-<<<TEST
-\400
-${/*}
-TEST;
-
-?>
---EXPECTF--
-Warning: Octal escape sequence overflow \400 is greater than \377 in %s on line %d
-
-Warning: Unterminated comment starting line %d in %s on line %d
-
-Parse error: syntax error, unexpected end of file in %s on line %d
index f2a3d15c748016263dcf1dadbb19f674520775b4..4b9e89ae67e164c4de1c452cb0c8739a697f26a2 100644 (file)
@@ -2190,8 +2190,11 @@ inline_char_handler:
 
        if (YYCURSOR < YYLIMIT) {
                YYCURSOR++;
-       } else if (!SCNG(heredoc_scan_ahead)) {
-               zend_error(E_COMPILE_WARNING, "Unterminated comment starting line %d", CG(zend_lineno));
+       } else {
+               zend_throw_exception_ex(zend_ce_parse_error, 0, "Unterminated comment starting line %d", CG(zend_lineno));
+               if (PARSER_MODE()) {
+                       RETURN_TOKEN(T_ERROR);
+               }
        }
 
        yyleng = YYCURSOR - SCNG(yy_text);