]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: sample: rename the "len" converter to "length"
authorWilly Tarreau <w@1wt.eu>
Fri, 15 Dec 2017 06:13:48 +0000 (07:13 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 15 Dec 2017 06:13:48 +0000 (07:13 +0100)
This converter was recently introduced by commit ed0d24e ("MINOR:
sample: add len converter").

As found by Cyril, it causes an issue in "http-request capture"
statements. The non-obvious problem is that an old syntax for sample
expressions and converters used to support a series of words, each
representing a converter. This used to be how the "stick" directives
were created initially. By having a converter called "len", a
statement such as "http-request capture foo len 10" considers "len"
as a converter and not as the capture length.

This obsolete syntax needs to be changed in 1.9 but it's too late
for other versions. It's worth noting that the same problem can
happen if converters are registered on the fly using Lua. Other
language keywords that currently have to be avoided in converters
include "id", "table", "if", "unless".

doc/configuration.txt
src/sample.c

index a9587129bc30262f88677f4dbe2f4253c0ebe0e3..87fc567292f1572cf1b078d7f8b41c83089cf903 100644 (file)
@@ -12941,7 +12941,7 @@ language(<value>[,<default>])
     use_backend english if en
     default_backend choose_your_language
 
-len
+length
   Get the length of the string. This can only be placed after a string
   sample fetch function or after a transformation keyword returning a string
   type. The result is of type integer.
index 213dd317bc08fa1f00e9f49e73785299806f9e75..ed2aee01024a8f792b0cee2cd3a6e354afe311c9 100644 (file)
@@ -1568,7 +1568,7 @@ static int sample_conv_djb2(const struct arg *arg_p, struct sample *smp, void *p
        return 1;
 }
 
-static int sample_conv_strlen(const struct arg *arg_p, struct sample *smp, void *private)
+static int sample_conv_length(const struct arg *arg_p, struct sample *smp, void *private)
 {
        int i = smp->data.u.str.len;
        smp->data.u.sint = i;
@@ -2796,7 +2796,7 @@ static struct sample_conv_kw_list sample_conv_kws = {ILH, {
        { "base64", sample_conv_bin2base64,0,            NULL, SMP_T_BIN,  SMP_T_STR  },
        { "upper",  sample_conv_str2upper, 0,            NULL, SMP_T_STR,  SMP_T_STR  },
        { "lower",  sample_conv_str2lower, 0,            NULL, SMP_T_STR,  SMP_T_STR  },
-       { "len",    sample_conv_strlen,    0,            NULL, SMP_T_STR,  SMP_T_SINT },
+       { "length", sample_conv_length,    0,            NULL, SMP_T_STR,  SMP_T_SINT },
        { "hex",    sample_conv_bin2hex,   0,            NULL, SMP_T_BIN,  SMP_T_STR  },
        { "hex2i",  sample_conv_hex2int,   0,            NULL, SMP_T_STR,  SMP_T_SINT },
        { "ipmask", sample_conv_ipmask,    ARG1(1,MSK4), NULL, SMP_T_IPV4, SMP_T_IPV4 },