Welcome! Log In Create A New Profile

Advanced

[njs] Fixed Array.prototype.concat() with exotic argument object.

Dmitry Volyntsev
January 18, 2022 10:38AM
details: https://hg.nginx.org/njs/rev/3e86977c253d
branches:
changeset: 1808:3e86977c253d
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Tue Jan 18 15:35:00 2022 +0000
description:
Fixed Array.prototype.concat() with exotic argument object.

The issue was introduced in 2c1382bab643.

diffstat:

src/njs_array.c | 2 +-
src/test/njs_unit_test.c | 7 +++++++
2 files changed, 8 insertions(+), 1 deletions(-)

diffs (29 lines):

diff -r 7467158d9f37 -r 3e86977c253d src/njs_array.c
--- a/src/njs_array.c Fri Jan 14 14:40:27 2022 +0000
+++ b/src/njs_array.c Tue Jan 18 15:35:00 2022 +0000
@@ -1743,7 +1743,7 @@ njs_array_prototype_concat(njs_vm_t *vm,
return NJS_ERROR;
}

- if (njs_is_fast_array(e)) {
+ if (njs_is_fast_array(e) || njs_fast_object(len)) {
for (k = 0; k < len; k++, length++) {
ret = njs_value_property_i64(vm, e, k, &retval);
if (njs_slow_path(ret != NJS_OK)) {
diff -r 7467158d9f37 -r 3e86977c253d src/test/njs_unit_test.c
--- a/src/test/njs_unit_test.c Fri Jan 14 14:40:27 2022 +0000
+++ b/src/test/njs_unit_test.c Tue Jan 18 15:35:00 2022 +0000
@@ -12857,6 +12857,13 @@ static njs_unit_test_t njs_test[] =
"a.concat(b)"),
njs_str("1,2,3,4,5") },

+ { njs_str("Boolean.prototype.length = 2;"
+ "Boolean.prototype[0] = 'a';"
+ "Boolean.prototype[1] = 'b';"
+ "Boolean.prototype[Symbol.isConcatSpreadable] = true;"
+ "[].concat(new Boolean(true))"),
+ njs_str("a,b") },
+
{ njs_str("var o = {}, n = 5381 /* NJS_DJB_HASH_INIT */;"
"while(n--) o[Symbol()] = 'test'; o[''];"),
njs_str("undefined") },
_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

[njs] Fixed Array.prototype.concat() with exotic argument object.

Dmitry Volyntsev 167 January 18, 2022 10:38AM



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

Online Users

Guests: 118
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