Welcome! Log In Create A New Profile

Advanced

[njs] Fixed String.prototype.split() for UTF8-invalid byte strings.

Dmitry Volyntsev
May 17, 2019 02:18PM
details: https://hg.nginx.org/njs/rev/e22397fd709a
branches:
changeset: 969:e22397fd709a
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Fri May 17 21:16:31 2019 +0300
description:
Fixed String.prototype.split() for UTF8-invalid byte strings.

This closes #161 issue on Github.

diffstat:

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

diffs (32 lines):

diff -r 9af8e1b5f3c1 -r e22397fd709a njs/njs_string.c
--- a/njs/njs_string.c Fri May 17 17:52:30 2019 +0300
+++ b/njs/njs_string.c Fri May 17 21:16:31 2019 +0300
@@ -2757,7 +2757,7 @@ njs_string_match_multiple(njs_vm_t *vm,


/*
- * String.split([string|regexp[, limit]])
+ * String.prototype.split([string|regexp[, limit]])
*/

static njs_ret_t
@@ -2838,7 +2838,8 @@ found:

/* Empty split string. */
if (p == next) {
- p = nxt_utf8_next(p, end);
+ p = (utf8 != NJS_STRING_BYTE) ? nxt_utf8_next(p, end)
+ : p + 1;
next = p;
}

@@ -2885,7 +2886,8 @@ found:

/* Empty split regexp. */
if (p == next) {
- p = nxt_utf8_next(p, end);
+ p = (utf8 != NJS_STRING_BYTE) ? nxt_utf8_next(p, end)
+ : p + 1;
next = p;
}

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

[njs] Fixed String.prototype.split() for UTF8-invalid byte strings.

Dmitry Volyntsev 179 May 17, 2019 02:18PM



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