]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: haterm: parse the arguments from the first '?' of the URI
authorAleksandar Lazic <al-haproxy@none.at>
Thu, 3 Dec 2026 20:34:41 +0000 (21:34 +0100)
committerFrederic Lecaille <flecaille@haproxy.com>
Fri, 4 Dec 2026 10:26:11 +0000 (11:26 +0100)
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 <noreply@anthropic.com>
Signed-off-by: Aleksandar Lazic <al-haproxy@none.at>
src/haterm.c

index 9b78967adc8dacdbbfbe1379ad644ca7c0d445b2..361e934cb3237900cf0f1528b69e51e6e359837d 100644 (file)
@@ -823,10 +823,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;