From: Andrey Zelenkov Date: Wed, 31 May 2017 17:36:01 +0000 (+0300) Subject: Fixed parseInt() leading white space ignoring. X-Git-Tag: 0.1.11~30 X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/static/gitweb.js?a=commitdiff_plain;h=59e9593eba2e067289a492c30a54c8b0b3d6f197;p=njs.git Fixed parseInt() leading white space ignoring. --- diff --git a/njs/njs_number.c b/njs/njs_number.c index 1d19d37e..c7c12102 100644 --- a/njs/njs_number.c +++ b/njs/njs_number.c @@ -709,10 +709,9 @@ njs_number_parse_int(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs, if (nargs > 1) { (void) njs_string_prop(&string, &args[1]); - p = string.start; end = string.start + string.size; - while (p < end) { + for (p = string.start; p < end; p++) { if (*p != ' ') { goto found; } diff --git a/njs/test/njs_unit_test.c b/njs/test/njs_unit_test.c index fe188837..fdff83a3 100644 --- a/njs/test/njs_unit_test.c +++ b/njs/test/njs_unit_test.c @@ -7150,6 +7150,9 @@ static njs_unit_test_t njs_test[] = { nxt_string("parseInt('0XaBc', 0)"), nxt_string("2748") }, + { nxt_string("parseInt(' 123')"), + nxt_string("123") }, + { nxt_string("parseInt('1010', 2)"), nxt_string("10") },