MINOR: sample/acl: use is_idchar() to locate the fetch/conv name

Instead of scanning a string looking for an end of line, ')' or ',',
let's only accept characters which are actually valid identifier
characters. This will let the parser know that in %[src], only "src"
is the sample fetch name, not "src]". This was done both for samples
and ACLs since they are the same here.
This commit is contained in:
Willy Tarreau 2020-02-14 18:27:10 +01:00
parent d4ad669051
commit ed2c662b01
2 changed files with 9 additions and 5 deletions

View File

@ -90,7 +90,7 @@ struct acl_keyword *find_acl_kw(const char *kw)
struct acl_kw_list *kwl;
kwend = kw;
while (*kwend && *kwend != '(' && *kwend != ',')
while (is_idchar(*kwend))
kwend++;
list_for_each_entry(kwl, &acl_keywords.list, list) {
@ -190,7 +190,8 @@ struct acl_expr *parse_acl_expr(const char **args, char **err, struct arg_list *
smp->arg_p = empty_arg_list;
/* look for the beginning of the subject arguments */
for (arg = args[0]; *arg && *arg != '(' && *arg != ','; arg++);
for (arg = args[0]; is_idchar(*arg); arg++)
;
endt = arg;
if (*endt == '(') {
@ -263,7 +264,8 @@ struct acl_expr *parse_acl_expr(const char **args, char **err, struct arg_list *
/* none ? end of converters */
break;
for (endw = begw; *endw && *endw != '(' && *endw != ','; endw++);
for (endw = begw; is_idchar(*endw); endw++)
;
free(ckw);
ckw = my_strndup(begw, endw - begw);

View File

@ -839,7 +839,8 @@ struct sample_expr *sample_parse_expr(char **str, int *idx, const char *file, in
int err_arg;
begw = str[*idx];
for (endw = begw; *endw && *endw != '(' && *endw != ','; endw++);
for (endw = begw; is_idchar(*endw); endw++)
;
if (endw == begw) {
memprintf(err_msg, "missing fetch method");
@ -949,7 +950,8 @@ struct sample_expr *sample_parse_expr(char **str, int *idx, const char *file, in
break;
}
for (endw = begw; *endw && *endw != '(' && *endw != ','; endw++);
for (endw = begw; is_idchar(*endw); endw++)
;
free(ckw);
ckw = my_strndup(begw, endw - begw);