Welcome! Log In Create A New Profile

Advanced

[njs] Fixed exception type for unsupported types in JSON.stringify().

Dmitry Volyntsev
April 20, 2018 09:44AM
details: http://hg.nginx.org/njs/rev/28d75187de15
branches:
changeset: 500:28d75187de15
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Fri Apr 20 16:42:10 2018 +0300
description:
Fixed exception type for unsupported types in JSON.stringify().

diffstat:

njs/njs_json.c | 4 ++++
njs/test/njs_unit_test.c | 3 +++
2 files changed, 7 insertions(+), 0 deletions(-)

diffs (27 lines):

diff -r cb7115e9fa1e -r 28d75187de15 njs/njs_json.c
--- a/njs/njs_json.c Fri Apr 20 16:42:08 2018 +0300
+++ b/njs/njs_json.c Fri Apr 20 16:42:10 2018 +0300
@@ -1184,6 +1184,10 @@ njs_json_parse_exception(njs_json_parse_
state->written = 1; \
ret = njs_json_append_value(stringify, value); \
if (nxt_slow_path(ret != NXT_OK)) { \
+ if (ret == NXT_DECLINED) { \
+ return NXT_ERROR; \
+ } \
+ \
goto memory_error; \
}

diff -r cb7115e9fa1e -r 28d75187de15 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Fri Apr 20 16:42:08 2018 +0300
+++ b/njs/test/njs_unit_test.c Fri Apr 20 16:42:10 2018 +0300
@@ -8708,6 +8708,9 @@ static njs_unit_test_t njs_test[] =
{ nxt_string("var e = URIError('e'); e.foo = 'E'; JSON.stringify(e)"),
nxt_string("{\"foo\":\"E\"}") },

+ { nxt_string("JSON.stringify($r)"),
+ nxt_string("TypeError: Non-serializable object") },
+
/* Ignoring named properties of an array. */

{ nxt_string("var a = [1,2]; a.a = 1;"
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Fixed exception type for unsupported types in JSON.stringify().

Dmitry Volyntsev 223 April 20, 2018 09:44AM



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

Online Users

Guests: 210
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready