From: Dmitry Volyntsev Date: Fri, 17 May 2019 18:16:31 +0000 (+0300) Subject: Fixed String.prototype.split() for UTF8-invalid byte strings. X-Git-Tag: 0.3.2~4 X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/static/gitweb.js?a=commitdiff_plain;h=8995984ade857048ee880d8b785c6b4f951ea60d;p=njs.git Fixed String.prototype.split() for UTF8-invalid byte strings. This closes #161 issue on Github. --- 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; }