[MINOR] show errors: encode backslash as well as non-ascii characters

These ones were not properly encoded, causing confusion on the output.
This commit is contained in:
Willy Tarreau 2009-03-12 08:18:33 +01:00
parent 8185cedcb3
commit 787bbd9b7a

View File

@ -1262,11 +1262,11 @@ static int dump_error_line(struct chunk *out, int size,
while (ptr < err->len) { while (ptr < err->len) {
c = err->buf[ptr]; c = err->buf[ptr];
if (isprint(c)) { if (isprint(c) && isascii(c) && c != '\\') {
if (out->len > end - 2) if (out->len > end - 2)
break; break;
out->str[out->len++] = c; out->str[out->len++] = c;
} else if (c == '\t' || c == '\n' || c == '\r' || c == '\e') { } else if (c == '\t' || c == '\n' || c == '\r' || c == '\e' || c == '\\') {
if (out->len > end - 3) if (out->len > end - 3)
break; break;
out->str[out->len++] = '\\'; out->str[out->len++] = '\\';
@ -1275,6 +1275,7 @@ static int dump_error_line(struct chunk *out, int size,
case '\n': c = 'n'; break; case '\n': c = 'n'; break;
case '\r': c = 'r'; break; case '\r': c = 'r'; break;
case '\e': c = 'e'; break; case '\e': c = 'e'; break;
case '\\': c = '\\'; break;
} }
out->str[out->len++] = c; out->str[out->len++] = c;
} else { } else {