]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: http-fetch: Ignore empty argument string for query()
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 11 Dec 2024 08:09:26 +0000 (09:09 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 11 Dec 2024 09:00:01 +0000 (10:00 +0100)
query() sample fetch function takes an optional argument string. During
configuration parsing, empty string must be ignored. It is especially
important when the sample is used with empty parenthesis. The argument is
optional and it is a list of options to configure the behavior of the sample
fetch. So it is logical to ignore empty strings.

This patch should fix the issue #2815. It must be backported to 3.1.

src/http_fetch.c

index 28fe8ae7a35234aeef939bc6fea694b5b22fc094..ebba87519b86462d45eebac69983862666a21e13 100644 (file)
@@ -2229,6 +2229,8 @@ int val_hdr(struct arg *arg, char **err_msg)
 
 int val_query(struct arg *args, char **err_msg)
 {
+       int val = 0;
+
        if (args[0].type == ARGT_STOP)
                return 1;
 
@@ -2237,14 +2239,17 @@ int val_query(struct arg *args, char **err_msg)
                return 0;
        }
 
-       if (chunk_strcmp(&args[0].data.str, "with_qm") != 0) {
-               memprintf(err_msg, "supported options are: 'with_qm'");
-               return 0;
+       if (args[0].data.str.data != 0) {
+               if (chunk_strcmp(&args[0].data.str, "with_qm") != 0) {
+                       memprintf(err_msg, "supported options are: 'with_qm'");
+                       return 0;
+               }
+               val = 1;
        }
 
        chunk_destroy(&args[0].data.str);
        args[0].type = ARGT_SINT;
-       args[0].data.sint = 1;
+       args[0].data.sint = val;
        return 1;
 
 }