[njs] Fixed parsing of invalid for-in statement.
Vadim Zhestikov
v.zhestikov at f5.com
Thu Jun 1 16:41:59 UTC 2023
details: https://hg.nginx.org/njs/rev/aa05db6d896f
branches:
changeset: 2144:aa05db6d896f
user: Vadim Zhestikov <v.zhestikov at f5.com>
date: Thu Jun 01 09:39:25 2023 -0700
description:
Fixed parsing of invalid for-in statement.
The issue was introduced in: b9d18d4dd34e
diffstat:
src/njs_parser.c | 4 ++++
src/test/njs_unit_test.c | 3 +++
2 files changed, 7 insertions(+), 0 deletions(-)
diffs (27 lines):
diff -r ab54ef24feac -r aa05db6d896f src/njs_parser.c
--- a/src/njs_parser.c Sun May 28 15:36:46 2023 +0100
+++ b/src/njs_parser.c Thu Jun 01 09:39:25 2023 -0700
@@ -5496,6 +5496,10 @@ njs_parser_for_expression_map_reparse(nj
{
njs_str_t *text;
+ if (parser->ret != NJS_OK && parser->node != NULL) {
+ return njs_parser_failed(parser);
+ }
+
if (parser->node == NULL) {
njs_lexer_in_fail_set(parser->lexer, 1);
diff -r ab54ef24feac -r aa05db6d896f src/test/njs_unit_test.c
--- a/src/test/njs_unit_test.c Sun May 28 15:36:46 2023 +0100
+++ b/src/test/njs_unit_test.c Thu Jun 01 09:39:25 2023 -0700
@@ -2969,6 +2969,9 @@ static njs_unit_test_t njs_test[] =
{ njs_str("for (a(b * in d) ;"),
njs_str("SyntaxError: Unexpected token \"in\" in 1") },
+ { njs_str("for(c=let c"),
+ njs_str("SyntaxError: Unexpected token \"let\" in 1") },
+
/* switch. */
{ njs_str("switch"),
More information about the nginx-devel
mailing list