summaryrefslogtreecommitdiff
path: root/www/squid/patches/patch-aj
blob: 41c667c962de247d1e38a264de89adc97719c9e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
$NetBSD: patch-aj,v 1.6 2002/10/13 16:43:21 taca Exp $

--- src/access_log.c.orig	Sun Jun 16 20:25:40 2002
+++ src/access_log.c
@@ -120,6 +120,8 @@ log_quote(const char *header)
 {
     int c;
     int i;
+    int log_all, check_name, log_this;
+    const struct _wordlist *wl;
     char *buf;
     char *buf_cursor;
     if (header == NULL) {
@@ -129,13 +131,41 @@ log_quote(const char *header)
     }
     buf = xcalloc(1, (strlen(header) * 3) + 1);
     buf_cursor = buf;
+
+    /* if empty or first keyword is "all", log all mime headers */
+    log_all = (!Config.log_mime_hdrs_list
+		|| strcasecmp(Config.log_mime_hdrs_list->key, "all") == 0);
+
     /*
      * We escape: \x00-\x1F"#%;<>?{}|\\\\^~`\[\]\x7F-\xFF 
      * which is the default escape list for the CPAN Perl5 URI module
      * modulo the inclusion of space (x40) to make the raw logs a bit
      * more readable.
      */
-    while ((c = *(const unsigned char *) header++) != '\0') {
+    check_name = 1;
+    log_this = 1;
+    for(; (c = *(const unsigned char *) header) != '\0'; header++) {
+	if (!log_all && check_name) {
+		/* loop over configured header names and only continue
+		 * if the current header is on the list */
+		wl = Config.log_mime_hdrs_list;
+		log_this = 0;
+		for(; wl; wl = wl->next) {
+			if (strncasecmp(wl->key, header, strlen(wl->key)) == 0){
+				log_this = 1;
+				break;
+			}
+		}
+		check_name = 0;
+	}
+	if (!log_this) {
+		if (c == '\n') {
+			/* check header name in next iteration */
+			check_name = 1;
+		}
+		continue;
+	}
+ 
 #if !OLD_LOG_MIME
 	if (c == '\r') {
 	    *buf_cursor++ = '\\';
@@ -143,6 +173,7 @@ log_quote(const char *header)
 	} else if (c == '\n') {
 	    *buf_cursor++ = '\\';
 	    *buf_cursor++ = 'n';
+	    check_name = 1;
 	} else
 #endif
 	    if (c <= 0x1F