summaryrefslogtreecommitdiff
path: root/www/squid/patches/patch-aj
blob: e791c1a589f6dd20c518a4f47ad52ffe99546800 (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.3 2000/11/02 10:31:39 jdolecek Exp $

--- access_log.c.orig	Thu Nov  2 10:00:04 2000
+++ access_log.c	Thu Nov  2 11:06:28 2000
@@ -122,6 +122,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) {
@@ -131,13 +133,41 @@ log_quote(const char *header)
     }
     buf = xcalloc((strlen(header) * 3) + 1, 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++ = '\\';
@@ -145,6 +175,7 @@ log_quote(const char *header)
 	} else if (c == '\n') {
 	    *buf_cursor++ = '\\';
 	    *buf_cursor++ = 'n';
+	    check_name = 1;
 	} else
 #endif
 	    if (c <= 0x1F