Welcome! Log In Create A New Profile

Advanced

[njs] Parser: catching errors parsing in await expression.

Alexander Borisov
September 02, 2021 12:36PM
details: https://hg.nginx.org/njs/rev/502be9e80244
branches:
changeset: 1703:502be9e80244
user: Alexander Borisov <alexander.borisov@nginx.com>
date: Thu Sep 02 19:33:03 2021 +0300
description:
Parser: catching errors parsing in await expression.

The bug was introduced in 92d10cd761e2.

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 f2410c8b80d9 -r 502be9e80244 src/njs_parser.c
--- a/src/njs_parser.c Thu Sep 02 19:32:52 2021 +0300
+++ b/src/njs_parser.c Thu Sep 02 19:33:03 2021 +0300
@@ -3504,6 +3504,10 @@ static njs_int_t
njs_parser_await_after(njs_parser_t *parser, njs_lexer_token_t *token,
njs_queue_link_t *current)
{
+ if (parser->ret != NJS_OK) {
+ return njs_parser_failed(parser);
+ }
+
parser->target->right = parser->node;
parser->node = parser->target;

diff -r f2410c8b80d9 -r 502be9e80244 src/test/njs_unit_test.c
--- a/src/test/njs_unit_test.c Thu Sep 02 19:32:52 2021 +0300
+++ b/src/test/njs_unit_test.c Thu Sep 02 19:33:03 2021 +0300
@@ -20517,6 +20517,9 @@ static njs_unit_test_t njs_test[] =
{ njs_str("function f(a) {}"
"(async function() {f('Number: ' + await 111)})"),
njs_str("SyntaxError: await in arguments not supported in 1") },
+
+ { njs_str("async function af() {await encrypt({},}"),
+ njs_str("SyntaxError: Unexpected token \"}\" in 1") },
};


_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Parser: catching errors parsing in await expression.

Alexander Borisov 75 September 02, 2021 12:36PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 83
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready