]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: cli: allow space escaping on the CLI
authorYves Lafon <ylafon@w3.org>
Mon, 8 Jun 2020 14:08:06 +0000 (16:08 +0200)
committerWilliam Lallemand <wlallemand@haproxy.org>
Fri, 19 Jun 2020 12:32:55 +0000 (14:32 +0200)
It was not possible to escape spaces over the CLI, making impossible the
insertion of new ACL entries with spaces from the CLI.

This patch fixes the escaping of spaces over the CLI.

It is now possible to launch "add acl agents.acl My\ User\ Agent" over
the CLI.

Could be backported in all stable branches.

Should fix issue #400.

src/cli.c

index 12dc8e648586afbb34528c70392f0aca5f01fb89..5912e21b0286e6d75f2538c9844466b04bfafdcd 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -526,7 +526,18 @@ static int cli_parse_request(struct appctx *appctx)
                        break;
 
                args[i] = p;
-               p += strcspn(p, " \t");
+               while (1) {
+                       p += strcspn(p, " \t\\");
+                       /* escaped chars using backlashes (\) */
+                       if (*p == '\\') {
+                               if (!*++p)
+                                       break;
+                               if (!*++p)
+                                       break;
+                       } else {
+                               break;
+                       }
+               }
                *p++ = 0;
 
                /* unescape backslashes (\) */