Project

General

Profile

Feature #2236 ยป mod_accesslog.patch

crypt, 2010-07-12 02:55

View differences:

mod_accesslog.c 2010-05-23 04:56:02.000000000 +0200
if (str->used == 0) return;
buffer_prepare_append(dest, str->used - 1);
for (unsigned int i = 0; i < str->used - 1; i++) {
if (str->ptr[i] >= ' ' && str->ptr[i] <= '~') {
/* printable chars */
buffer_append_string_len(dest, &str->ptr[i], 1);
} else switch (str->ptr[i]) {
case '"':
BUFFER_APPEND_STRING_CONST(dest, "\\\"");
break;
case '\\':
BUFFER_APPEND_STRING_CONST(dest, "\\\\");
break;
case '\b':
BUFFER_APPEND_STRING_CONST(dest, "\\b");
break;
case '\n':
BUFFER_APPEND_STRING_CONST(dest, "\\n");
break;
case '\r':
BUFFER_APPEND_STRING_CONST(dest, "\\r");
break;
case '\t':
BUFFER_APPEND_STRING_CONST(dest, "\\t");
break;
case '\v':
BUFFER_APPEND_STRING_CONST(dest, "\\v");
break;
default: {
/* non printable char => \xHH */
char hh[5] = {'\\','x',0,0,0};
char h = str->ptr[i] / 16;
hh[2] = (h > 9) ? (h - 10 + 'A') : (h + '0');
h = str->ptr[i] % 16;
hh[3] = (h > 9) ? (h - 10 + 'A') : (h + '0');
buffer_append_string_len(dest, &hh[0], 4);
char *ptr, *start, *end;
for (ptr = start = str->ptr, end = str->ptr + str->used - 1; ptr < end; ptr++) {
if (*ptr >= ' ' && *ptr <= '~') {
/* void */
} else {
buffer_append_string_len(dest, start, ptr - start);
start = ptr + 1;
switch (*ptr) {
case '"':
BUFFER_APPEND_STRING_CONST(dest, "\\\"");
break;
case '\\':
BUFFER_APPEND_STRING_CONST(dest, "\\\\");
break;
case '\b':
BUFFER_APPEND_STRING_CONST(dest, "\\b");
break;
case '\n':
BUFFER_APPEND_STRING_CONST(dest, "\\n");
break;
case '\r':
BUFFER_APPEND_STRING_CONST(dest, "\\r");
break;
case '\t':
BUFFER_APPEND_STRING_CONST(dest, "\\t");
break;
case '\v':
BUFFER_APPEND_STRING_CONST(dest, "\\v");
break;
default: {
/* non printable char => \xHH */
char hh[5] = {'\\','x',0,0,0};
char h = *ptr / 16;
hh[2] = (h > 9) ? (h - 10 + 'A') : (h + '0');
h = *ptr % 16;
hh[3] = (h > 9) ? (h - 10 + 'A') : (h + '0');
buffer_append_string_len(dest, &hh[0], 4);
}
break;
}
break;
}
}
if (start < end) {
buffer_append_string_len(dest, start, end - start);
}
}
static int accesslog_parse_format(server *srv, format_fields *fields, buffer *format) {
    (1-1/1)