summaryrefslogtreecommitdiff
path: root/src/mod_accesslog.c
diff options
context:
space:
mode:
authorStefan Bühler <stbuehler@web.de>2012-04-19 13:02:08 +0000
committerStefan Bühler <stbuehler@web.de>2012-04-19 13:02:08 +0000
commitab0fa7d873a88ae8aa36e22b292d56cb86ede8fd (patch)
treeee4a8e97a5829517990359eeaeb7ff208d7bbe76 /src/mod_accesslog.c
parent01f9debec31c8696d324db3d1b6a092a4e853077 (diff)
downloadlighttpd-git-ab0fa7d873a88ae8aa36e22b292d56cb86ede8fd.tar.gz
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
Diffstat (limited to 'src/mod_accesslog.c')
-rw-r--r--src/mod_accesslog.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/mod_accesslog.c b/src/mod_accesslog.c
index 420037eb..febfcae4 100644
--- a/src/mod_accesslog.c
+++ b/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);
}