]> git.kaiwu.me - njs.git/commitdiff
HTTP: remove the key limit from r.args parsing
authorDmitry Volyntsev <xeioex@nginx.com>
Wed, 2 Dec 2026 01:39:10 +0000 (17:39 -0800)
committerDmitry Volyntsev <xeioexception@gmail.com>
Thu, 3 Dec 2026 01:27:35 +0000 (17:27 -0800)
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.

external/njs_query_string_module.c
external/qjs_query_string_module.c
nginx/t/js_args.t

index 1eecb9a27e57e17a9fc7f9d57d857df5f8a8055a..c604e4df05d3d54cc5e34de25783d10f3c72a80d 100644 (file)
@@ -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);
 }
 
 
index 2ff23927f4b22c8760c90d43276a8849109d93bb..75228784b62d5e76d3b5e8ca76be64d9c69c3c1e 100644 (file)
@@ -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);
 }
 
 
index 609698739e358cddaca74923ca694138790b7bfc..662f3b382d7a23496af52e921b6a006838a3d9e3 100644 (file)
@@ -133,7 +133,7 @@ $t->write_file('test.js', <<EOF);
 
 EOF
 
-$t->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 {