]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: dumpstat: make the CLI parser understand the backslash as an escape char
authorThierry FOURNIER <tfournier@exceliance.fr>
Tue, 10 Dec 2013 17:54:58 +0000 (18:54 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 12 Dec 2013 14:56:09 +0000 (15:56 +0100)
We'll need to pass patterns on the CLI for lookups. Till now there was no
need for a backslash, so it's still time to support them just like in the
config file.

src/dumpstats.c

index d1518b8db2ef94b754b2055ae914e2d90a342946..96c5cead4aea2ee125556762c836365af054554a 100644 (file)
@@ -926,6 +926,7 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line)
        struct appctx *appctx = __objt_appctx(si->end);
        char *args[MAX_STATS_ARGS + 1];
        int arg;
+       int i, j;
 
        while (isspace((unsigned char)*line))
                line++;
@@ -934,7 +935,12 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line)
        args[arg] = line;
 
        while (*line && arg < MAX_STATS_ARGS) {
-               if (isspace((unsigned char)*line)) {
+               if (*line == '\\') {
+                       line++;
+                       if (*line == '\0')
+                               break;
+               }
+               else if (isspace((unsigned char)*line)) {
                        *line++ = '\0';
 
                        while (isspace((unsigned char)*line))
@@ -950,6 +956,20 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line)
        while (++arg <= MAX_STATS_ARGS)
                args[arg] = line;
 
+       /* remove \ */
+       arg = 0;
+       while (*args[arg] != '\0') {
+               j = 0;
+               for (i=0; args[arg][i] != '\0'; i++) {
+                       if (args[arg][i] == '\\')
+                               continue;
+                       args[arg][j] = args[arg][i];
+                       j++;
+               }
+               args[arg][j] = '\0';
+               arg++;
+       }
+
        appctx->ctx.stats.flags = 0;
        if (strcmp(args[0], "show") == 0) {
                if (strcmp(args[1], "stat") == 0) {