Welcome! Log In Create A New Profile

Advanced

[njs] Fixed String.prototype.match() for byte strings with regex arg.

Alexander Borisov
July 16, 2019 10:34AM
details: https://hg.nginx.org/njs/rev/8ac396f1a20c
branches:
changeset: 1053:8ac396f1a20c
user: Alexander Borisov <alexander.borisov@nginx.com>
date: Tue Jul 16 17:32:11 2019 +0300
description:
Fixed String.prototype.match() for byte strings with regex arg.

diffstat:

njs/njs_string.c | 3 ++-
njs/test/njs_unit_test.c | 3 +++
2 files changed, 5 insertions(+), 1 deletions(-)

diffs (26 lines):

diff -r 9e6098cb3b2e -r 8ac396f1a20c njs/njs_string.c
--- a/njs/njs_string.c Tue Jul 16 17:32:10 2019 +0300
+++ b/njs/njs_string.c Tue Jul 16 17:32:11 2019 +0300
@@ -2757,7 +2757,8 @@ njs_string_match_multiple(njs_vm_t *vm,

if (captures[1] == 0) {
if (start < end) {
- p = nxt_utf8_next(start, end);
+ p = (utf8 != NJS_STRING_BYTE) ? nxt_utf8_next(start, end)
+ : start + 1;
string.size = end - p;

} else {
diff -r 9e6098cb3b2e -r 8ac396f1a20c njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Tue Jul 16 17:32:10 2019 +0300
+++ b/njs/test/njs_unit_test.c Tue Jul 16 17:32:11 2019 +0300
@@ -5832,6 +5832,9 @@ static njs_unit_test_t njs_test[] =
"a +' '+ a.length"),
nxt_string("αα 4") },

+ { nxt_string("typeof String.bytesFrom(Array(15).fill(0xE3)).match(/^/g)"),
+ nxt_string("object") },
+
{ nxt_string("'abc'.split()"),
nxt_string("abc") },

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

[njs] Fixed String.prototype.match() for byte strings with regex arg.

Alexander Borisov 185 July 16, 2019 10:34AM



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

Online Users

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