From 8995984ade857048ee880d8b785c6b4f951ea60d Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Fri, 17 May 2019 21:16:31 +0300 Subject: [PATCH] Fixed String.prototype.split() for UTF8-invalid byte strings. This closes #161 issue on Github. --- njs/njs_string.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/njs/njs_string.c b/njs/njs_string.c index ae3f9718..a3a3d74f 100644 --- a/njs/njs_string.c +++ b/njs/njs_string.c @@ -2757,7 +2757,7 @@ njs_string_match_multiple(njs_vm_t *vm, njs_value_t *args, /* - * 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; } -- 2.47.3