Hi.

Here is another fix, for the multi question mark bug: the example of the documentation, "/?r=500?s=0?c=0?t=1000", only applies the last argument. This fix should be backported to 3.4.


Regards
Aleks
From 50e0cb1ae588f392e9d6b19fd1511da8935f6768 Mon Sep 17 00:00:00 2001
From: Aleksandar Lazic <[email protected]>
Date: Thu, 3 Dec 2026 21:35:39 +0100
Subject: [PATCH 2/2] REGTESTS: haterm: check the arguments separated by '?'
 and others

Check that all the arguments of the URI are used when they are
separated by '?', as in the example of the documentation, and by the
other delimiters '&', ',', ';' and '/'.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Aleksandar Lazic <[email protected]>
---
 reg-tests/haterm/haterm_uri_args.vtc | 38 ++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 reg-tests/haterm/haterm_uri_args.vtc

diff --git a/reg-tests/haterm/haterm_uri_args.vtc b/reg-tests/haterm/haterm_uri_args.vtc
new file mode 100644
index 000000000..94e165aea
--- /dev/null
+++ b/reg-tests/haterm/haterm_uri_args.vtc
@@ -0,0 +1,38 @@
+varnishtest "haterm: arguments of the URI and their delimiters"
+
+# The arguments start after the first '?' of the URI and may be separated by
+# any of '&', '?', ',', ';' and '/', as documented in doc/haterm.txt.
+
+feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(3.4-dev5)'"
+feature ignore_unknown_macro
+
+haproxy h1 -conf {
+    defaults
+	timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
+	timeout client  "${HAPROXY_TEST_TIMEOUT-5s}"
+	timeout server  "${HAPROXY_TEST_TIMEOUT-5s}"
+
+    frontend fe
+	mode haterm
+	bind "fd@${fe}"
+} -start
+
+client c1 -connect ${h1_fe_sock} {
+	# the example of the documentation: all the arguments are used
+	txreq -url "/?r=500?s=0?c=0?t=10"
+	rxresp
+	expect resp.status == 500
+	expect resp.http.cache-control == "no-cache"
+	expect resp.bodylen == 0
+
+	txreq -url "/?r=404&s=10"
+	rxresp
+	expect resp.status == 404
+	expect resp.bodylen == 10
+
+	txreq -url "/?r=403,s=20;c=0/s=30"
+	rxresp
+	expect resp.status == 403
+	expect resp.http.cache-control == "no-cache"
+	expect resp.bodylen == 30
+} -run
-- 
2.56.1

From 4bc6473f874c338335a328295a00babe3d4337ad Mon Sep 17 00:00:00 2001
From: Aleksandar Lazic <[email protected]>
Date: Thu, 3 Dec 2026 21:34:41 +0100
Subject: [PATCH 1/2] BUG/MINOR: haterm: parse the arguments from the first '?'
 of the URI

The URI parser looked for the last '?' of the URI instead of the first
one, so only the arguments after the last '?' were used. The example
of the documentation and of the help page, "/?r=500?s=0?c=0?t=1000",
thus only applied "t=1000" and returned a 200. httpterm used the first
'?', and the arguments loop already accepts '?' as a delimiter between
arguments, like '&', ',', ';' and '/'.

Let's stop at the first '?'.

This was introduced with haterm by commit c9d47804d ("MINOR: haterm:
add haterm HTTP server"), so it should be backported to 3.4.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Aleksandar Lazic <[email protected]>
---
 src/haterm.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/haterm.c b/src/haterm.c
index 26eddc1ea..ae8f6e75b 100644
--- a/src/haterm.c
+++ b/src/haterm.c
@@ -758,10 +758,15 @@ static void hstream_parse_uri(struct ist uri, struct hstream *hs)
 	/* we'll check for the following URIs :
 	 * /?{s=<size>|r=<resp>|t=<time>|c=<cache>}[&{...}]
 	 * /? to get the help page.
+	 * The arguments start after the first '?', the next ones are
+	 * delimiters like '&'.
 	 */
-	while (p < end)
-		if (*p++ == '?')
+	while (p < end) {
+		if (*p++ == '?') {
 			next = p;
+			break;
+		}
+	}
 
 	if (next) {
 		arg = next;
-- 
2.56.1

Reply via email to