Browse Source

Fix access log escaping of " and \\ (fixes #1551)

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2831 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.31
Stefan Bühler 10 years ago
parent
commit
ab0fa7d873
  1. 1
      NEWS
  2. 9
      src/mod_accesslog.c

1
NEWS

@ -10,6 +10,7 @@ NEWS
* disable mmap by default (fixes #2391)
* buffer_caseless_compare: always convert letters to lowercase to get transitive results, fixing array lookups (fixes #2405)
* Fix handling of empty header list entries in http_request_split_value, fixing invalid read in valgrind (fixes #2413)
* Fix access log escaping of " and \\ (fixes #1551)
- 1.4.30 - 2011-12-18
* Always use our 'own' md5 implementation, fixes linking issues on MacOS (fixes #2331)

9
src/mod_accesslog.c

@ -165,7 +165,8 @@ static void accesslog_append_escaped(buffer *dest, buffer *str) {
buffer_prepare_append(dest, str->used - 1);
for (ptr = start = str->ptr, end = str->ptr + str->used - 1; ptr < end; ptr++) {
if (*ptr >= ' ' && *ptr <= '~') {
char const c = *ptr;
if (c >= ' ' && c <= '~' && c != '"' && c != '\\') {
/* nothing to change, add later as one block */
} else {
/* copy previous part */
@ -174,7 +175,7 @@ static void accesslog_append_escaped(buffer *dest, buffer *str) {
}
start = ptr + 1;
switch (*ptr) {
switch (c) {
case '"':
BUFFER_APPEND_STRING_CONST(dest, "\\\"");
break;
@ -199,9 +200,9 @@ static void accesslog_append_escaped(buffer *dest, buffer *str) {
default: {
/* non printable char => \xHH */
char hh[5] = {'\\','x',0,0,0};
char h = *ptr / 16;
char h = c / 16;
hh[2] = (h > 9) ? (h - 10 + 'A') : (h + '0');
h = *ptr % 16;
h = c % 16;
hh[3] = (h > 9) ? (h - 10 + 'A') : (h + '0');
buffer_append_string_len(dest, &hh[0], 4);
}

Loading…
Cancel
Save