]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: vars: make the tcp/http unset-var() action support conditions
authorWilly Tarreau <w@1wt.eu>
Tue, 4 Jun 2019 14:43:29 +0000 (16:43 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 4 Jun 2019 14:48:15 +0000 (16:48 +0200)
Patrick Hemmer reported that http-request unset-var(foo) if ... fails to
parse. The reason is that it reuses the same parser as "set-var(foo)" which
makes a special case of the arguments, supposed to be a sample expression
for set-var, but which must not exist for unset-var. Unfortunately the
parser finds "if" or "unless" and believes it's an expression. Let's simply
drop the test so that the outer rule parser deals with potential extraneous
keywords.

This should be backported to all versions supporting unset-var().

src/vars.c

index 1d83c186aa8d4d507776e369f0839a7db3d576ea..49ff672756b1eb5706be2811908f50251301f30f 100644 (file)
@@ -697,6 +697,7 @@ static int conv_check_var(struct arg *args, struct sample_conv *conv,
  * the format:
  *
  *   set-var(<variable-name>) <expression>
+ *   unset-var(<variable-name>)
  *
  * It returns ACT_RET_PRS_ERR if fails and <err> is filled with an error
  * message. Otherwise, it returns ACT_RET_PRS_OK and the variable <expr>
@@ -740,10 +741,6 @@ static enum act_parse_ret parse_store(const char **args, int *arg, struct proxy
        /* There is no fetch method when variable is unset. Just set the right
         * action and return. */
        if (!set_var) {
-               if (*args[*arg]) {
-                       memprintf(err, "fetch method not supported");
-                       return ACT_RET_PRS_ERR;
-               }
                rule->action     = ACT_CUSTOM;
                rule->action_ptr = action_clear;
                return ACT_RET_PRS_OK;