From: Dmitry Volyntsev Date: Wed, 2 Dec 2026 01:39:10 +0000 (-0800) Subject: HTTP: remove the key limit from r.args parsing X-Git-Url: https://git.kaiwu.me/web/http/static/%7B@url%7D?a=commitdiff_plain;h=add65fc1d46abdb7329e64853284654d0b7ff562;p=njs.git HTTP: remove the key limit from r.args parsing Previously, njs_vm_query_string_parse() and qjs_vm_query_string_parse() stopped parsing r.args after 1000 segments, empty ones included, although r.args is documented without a key limit and the query string size is already bounded by large_client_header_buffers. Parse r.args without a key limit. The issue was introduced in 83a47d7c (0.7.6) and, for QuickJS, in adbb9280. Changed behaviour: - r.args contains all query string arguments. It used to stop after the first 1000 segments. --- diff --git a/external/njs_query_string_module.c b/external/njs_query_string_module.c index 1eecb9a2..c604e4df 100644 --- a/external/njs_query_string_module.c +++ b/external/njs_query_string_module.c @@ -474,7 +474,7 @@ njs_vm_query_string_parse(njs_vm_t *vm, u_char *start, u_char *end, njs_value_t *retval) { return njs_query_string_parser(vm, start, end, &njs_sep_default, - &njs_eq_default, NULL, 1000, retval); + &njs_eq_default, NULL, 0, retval); } diff --git a/external/qjs_query_string_module.c b/external/qjs_query_string_module.c index 2ff23927..75228784 100644 --- a/external/qjs_query_string_module.c +++ b/external/qjs_query_string_module.c @@ -483,7 +483,7 @@ exception: JSValue qjs_vm_query_string_parse(JSContext *cx, u_char *start, u_char *end) { - return qjs_query_string_parser(cx, start, end, NULL, NULL, JS_NULL, 1000); + return qjs_query_string_parser(cx, start, end, NULL, NULL, JS_NULL, 0); } diff --git a/nginx/t/js_args.t b/nginx/t/js_args.t index 60969873..662f3b38 100644 --- a/nginx/t/js_args.t +++ b/nginx/t/js_args.t @@ -133,7 +133,7 @@ $t->write_file('test.js', <try_run('no njs')->plan(32); +$t->try_run('no njs')->plan(34); ############################################################################### @@ -225,6 +225,16 @@ is(get_json('/object?a=%D8%C2%A2'), qq/{"a":"\x{fffd}\x{a2}"}/, is(get_json('/object?a=%ED%A0%80'), qq/{"a":"\x{fffd}\x{fffd}\x{fffd}"}/, 'UTF-8 encoded surrogate'); +TODO: { +local $TODO = 'not yet' unless has_version('1.0.3'); + +is(get_json('/object?' . ('&' x 1000) . 'a=1'), '{"a":"1"}', + 'r.args after 1000 empty segments'); +like(http_get('/keys?' . ('a=1&' x 1000) . 'b=2'), qr/^a,b$/m, + 'r.args after 1000 segments'); + +} + ############################################################################### sub has_version {