mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-18 01:11:01 +01:00
BUG/MEDIUM: config: for word expansion, empty or non-existing are the same
Amaury reported a case where "${FOO[*]}" still produces an empty field.
It happens if the variable is defined but does not contain any non-space
characters. The reason is that we special-case word expansion only on
non-existing vars. Let's change the ordering of operations so that word-
expanded vars always pretend the current arg is not an empty quote, so
that we don't make any difference between a non-existing var and an
empty one.
No backport is needed unless commit 1968731765 ("BUG/MEDIUM: config:
solve the empty argument problem again") is.
This commit is contained in:
parent
b26a6d50c6
commit
137d5ba93f
20
src/tools.c
20
src/tools.c
@ -6430,6 +6430,15 @@ uint32_t parse_line(char *in, char *out, size_t *outlen, char **args, int *nbarg
|
|||||||
brace = NULL;
|
brace = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (word_expand) {
|
||||||
|
/* If an empty or unknown env variable was passed as an array,
|
||||||
|
* we pretend the quotes were not empty, which will be sufficient
|
||||||
|
* to avoid creating a new arg. This is permitted and results
|
||||||
|
* in not creating any arg and dropping the surrounding quotes.
|
||||||
|
*/
|
||||||
|
empty_quote = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
unknown_var_name = NULL;
|
unknown_var_name = NULL;
|
||||||
while (*value) {
|
while (*value) {
|
||||||
@ -6461,16 +6470,7 @@ uint32_t parse_line(char *in, char *out, size_t *outlen, char **args, int *nbarg
|
|||||||
arg_start = outpos;
|
arg_start = outpos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (word_expand) {
|
else if (!word_expand) {
|
||||||
/* An empty or unknown env variable was passed as an array.
|
|
||||||
* This is permitted and results in not creating any arg and
|
|
||||||
* dropping the surrounding quotes. Here we pretend the quotes
|
|
||||||
* were not empty, which will be sufficient to avoid creating
|
|
||||||
* a new arg.
|
|
||||||
*/
|
|
||||||
empty_quote = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* An unmatched environment variable was parsed, it must
|
/* An unmatched environment variable was parsed, it must
|
||||||
* count as an argument.
|
* count as an argument.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user