]> git.kaiwu.me - haproxy.git/commitdiff
Revert "BUG/MINOR: config: Stopped parsing upon unmatched environment variables"
authorWilly Tarreau <w@1wt.eu>
Tue, 24 Jun 2025 16:18:18 +0000 (18:18 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 24 Jun 2025 16:22:15 +0000 (18:22 +0200)
This reverts commit ff8db5a85d60b21a711f8707791119adbbcffadc.

As explained in commit #2367, finally the fix above was incorrect because
it causes other trouble such as this:

     log "192.168.100.${NODE}" "local0"

being resolved to this:

     log 192.168.100.local0

when NODE does not exist due to the loss of the spaces. In fact, while none
of us was well aware of this, when the user had:

     server app 127.0.0.1:80 "${NO_CHECK}" weight 123

in fact they should have written it this way:

     server app 127.0.0.1:80 "${NO_CHECK[*]}" weight 123

so that the variable is expanded to zero, one or multiple words, leaving
no empty arg (like in shell). This is supported since 2.3 with commit
fa41cb6 so the right fix is in the config, let's revert the fix.

This should be backported to *some* versions, but the risk that some
configs were altered to rely on the broken fix is not null. At least
recent LTS should be reverted.

src/tools.c

index 731d8f93cf5de285a65f4fe22bcf122a79ade8a4..f68ac886345196c62113c68a150a9fb3a2e562d7 100644 (file)
@@ -6449,20 +6449,8 @@ uint32_t parse_line(char *in, char *out, size_t *outlen, char **args, int *nbarg
                                }
                        }
                        else {
-                               /* An unmatched environment variable was parsed.
-                                * Let's skip the trailing double-quote character
-                                * and spaces.
-                                */
+                               /* An unmatched environment variable was parsed. */
                                in_arg = 1;
-                               if (likely(*var_name != '.') && *in == '"') {
-                                       in++;
-                                       while (isspace((unsigned char)*in))
-                                               in++;
-                                       if (dquote) {
-                                               dquote = 0;
-                                               quote = NULL;
-                                       }
-                               }
                        }
                        word_expand = NULL;
                }