]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stats: Escape equals sign on socket dump
authorChad Lavoie <clavoie@haproxy.com>
Tue, 4 Oct 2016 20:10:40 +0000 (16:10 -0400)
committerWilly Tarreau <w@1wt.eu>
Tue, 25 Oct 2016 20:15:22 +0000 (22:15 +0200)
Greetings,

Was recently working with a stick table storing URL's and one had an
equals sign in it (e.g. 127.0.0.1/f=ab) which made it difficult to
easily split the key and value without a regex.

This patch will change it so that the key looks like
"key=127.0.0.1/f\=ab" instead of "key=127.0.0.1/f=ab".

Not very important given that there are ways to work around it.

Thanks,

- Chad

src/dumpstats.c

index 4647fb8491b771f2fd3ff9ffc7e6c42b2c883c83..8d43ce559cf83479cd8f1bb79a1c9f88ad9f1a51 100644 (file)
@@ -639,7 +639,7 @@ static void stats_dump_csv_header()
 
 /* print a string of text buffer to <out>. The format is :
  * Non-printable chars \t, \n, \r and \e are * encoded in C format.
- * Other non-printable chars are encoded "\xHH". Space and '\' are also escaped.
+ * Other non-printable chars are encoded "\xHH". Space, '\', and '=' are also escaped.
  * Print stopped if null char or <bsize> is reached, or if no more place in the chunk.
  */
 static int dump_text(struct chunk *out, const char *buf, int bsize)
@@ -649,12 +649,12 @@ static int dump_text(struct chunk *out, const char *buf, int bsize)
 
        while (buf[ptr] && ptr < bsize) {
                c = buf[ptr];
-               if (isprint(c) && isascii(c) && c != '\\' && c != ' ') {
+               if (isprint(c) && isascii(c) && c != '\\' && c != ' ' && c != '=') {
                        if (out->len > out->size - 1)
                                break;
                        out->str[out->len++] = c;
                }
-               else if (c == '\t' || c == '\n' || c == '\r' || c == '\e' || c == '\\' || c == ' ') {
+               else if (c == '\t' || c == '\n' || c == '\r' || c == '\e' || c == '\\' || c == ' ' || c == '=') {
                        if (out->len > out->size - 2)
                                break;
                        out->str[out->len++] = '\\';
@@ -665,6 +665,7 @@ static int dump_text(struct chunk *out, const char *buf, int bsize)
                        case '\r': c = 'r'; break;
                        case '\e': c = 'e'; break;
                        case '\\': c = '\\'; break;
+                       case '=': c = '='; break;
                        }
                        out->str[out->len++] = c;
                }