Welcome! Log In Create A New Profile

Advanced

[njs] Fixed Unicode Escaping in JSON.stringify() according to spec.

Dmitry Volyntsev
February 26, 2020 09:50AM
details: https://hg.nginx.org/njs/rev/6444ae6ab276
branches:
changeset: 1339:6444ae6ab276
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Wed Feb 26 17:48:46 2020 +0300
description:
Fixed Unicode Escaping in JSON.stringify() according to spec.

Lowecase hexadecimal number are required.

diffstat:

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

diffs (33 lines):

diff -r 061afad25256 -r 6444ae6ab276 src/njs_json.c
--- a/src/njs_json.c Tue Feb 25 16:03:20 2020 +0300
+++ b/src/njs_json.c Wed Feb 26 17:48:46 2020 +0300
@@ -1610,7 +1610,7 @@ njs_json_append_string(njs_chb_t *chain,
njs_string_prop_t string;

static char hex2char[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
+ '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };

(void) njs_string_prop(&string, value);

@@ -1619,7 +1619,7 @@ njs_json_append_string(njs_chb_t *chain,
utf8 = (string.length != 0 && string.length != string.size);

size = njs_max(string.size + 2, 7);
- dst = njs_chb_reserve(chain, string.size + 2);
+ dst = njs_chb_reserve(chain, size);
if (njs_slow_path(dst == NULL)) {
return;
}
diff -r 061afad25256 -r 6444ae6ab276 src/test/njs_unit_test.c
--- a/src/test/njs_unit_test.c Tue Feb 25 16:03:20 2020 +0300
+++ b/src/test/njs_unit_test.c Wed Feb 26 17:48:46 2020 +0300
@@ -15612,7 +15612,7 @@ static njs_unit_test_t njs_test[] =
njs_str("\"\\n\\t\\r\\\"\\f\\b\"") },

{ njs_str("JSON.stringify('\x00\x01\x02\x1f')"),
- njs_str("\"\\u0000\\u0001\\u0002\\u001F\"") },
+ njs_str("\"\\u0000\\u0001\\u0002\\u001f\"") },

{ njs_str("JSON.stringify('abc\x00')"),
njs_str("\"abc\\u0000\"") },
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Fixed Unicode Escaping in JSON.stringify() according to spec.

Dmitry Volyntsev 80 February 26, 2020 09:50AM



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

Online Users

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