X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=filters.c;h=886239a0ee8014d1bf49e2b185934e8deb1b89c0;hb=7c6b68ca9c6904520e7a69907be810b8dc679274;hp=de38b56ebf00f432d5aec3e98901db64028fe488;hpb=1b65660a5bb4e9d8511906406ebcc8a008c7baee;p=privoxy.git diff --git a/filters.c b/filters.c index de38b56e..886239a0 100644 --- a/filters.c +++ b/filters.c @@ -1,4 +1,4 @@ -const char filters_rcs[] = "$Id: filters.c,v 1.60 2006/07/18 14:48:46 david__schmidt Exp $"; +const char filters_rcs[] = "$Id: filters.c,v 1.65 2006/09/21 12:54:43 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/filters.c,v $ @@ -39,6 +39,24 @@ const char filters_rcs[] = "$Id: filters.c,v 1.60 2006/07/18 14:48:46 david__sch * * Revisions : * $Log: filters.c,v $ + * Revision 1.65 2006/09/21 12:54:43 fabiankeil + * Fix +redirect{}. Didn't work with -fast-redirects. + * + * Revision 1.64 2006/08/31 10:55:49 fabiankeil + * Block requests for untrusted URLs with status + * code 403 instead of 200. + * + * Revision 1.63 2006/08/31 10:11:28 fabiankeil + * Don't free p which is still in use and will be later + * freed by free_map(). Don't claim the referrer is unknown + * when the client didn't set one. + * + * Revision 1.62 2006/08/14 00:27:47 david__schmidt + * Feature request 595948: Re-Filter logging in single line + * + * Revision 1.61 2006/08/03 02:46:41 david__schmidt + * Incorporate Fabian Keil's patch work: http://www.fabiankeil.de/sourcecode/privoxy/ + * * Revision 1.60 2006/07/18 14:48:46 david__schmidt * Reorganizing the repository: swapping out what was HEAD (the old 3.1 branch) * with what was really the latest development (the v_3_0_branch branch) @@ -754,7 +772,7 @@ struct http_response *block_url(struct client_state *csp) if (((csp->action->flags & ACTION_IMAGE_BLOCKER) != 0) && is_imageurl(csp)) { - char *p; + char *p; /* determine HOW images should be blocked */ p = csp->action->string[ACTION_STRING_IMAGE_BLOCKER]; @@ -962,7 +980,7 @@ struct http_response *block_url(struct client_state *csp) * Function : trust_url FIXME: I should be called distrust_url * * Description : Calls is_untrusted_url to determine if the URL is trusted - * and if not, returns a HTTP 304 response with a reject message. + * and if not, returns a HTTP 403 response with a reject message. * * Parameters : * 1 : csp = Current client state (buffers, headers, etc...) @@ -996,8 +1014,9 @@ struct http_response *trust_url(struct client_state *csp) return cgi_error_memory(); } + rsp->status = strdup("403 Request blocked by Privoxy"); exports = default_exports(csp, NULL); - if (exports == NULL) + if (exports == NULL || rsp->status == NULL) { free_http_response(rsp); return cgi_error_memory(); @@ -1016,7 +1035,7 @@ struct http_response *trust_url(struct client_state *csp) } else { - if (!err) err = map(exports, "referrer", 1, "unknown", 1); + if (!err) err = map(exports, "referrer", 1, "none set", 1); } if (err) @@ -1036,7 +1055,6 @@ struct http_response *trust_url(struct client_state *csp) string_append(&p, buf); } err = map(exports, "trusted-referrers", 1, p, 0); - freez(p); if (err) { @@ -1059,7 +1077,6 @@ struct http_response *trust_url(struct client_state *csp) string_append(&p, buf); } err = map(exports, "trust-info", 1, p, 0); - freez(p); } else { @@ -1129,7 +1146,7 @@ struct http_response *redirect_url(struct client_state *csp) { q = csp->action->string[ACTION_STRING_REDIRECT]; } - else + else if ((csp->action->flags & ACTION_FAST_REDIRECTS)) { redirect_mode = csp->action->string[ACTION_STRING_FAST_REDIRECTS]; if (0 == strcmpic(redirect_mode, "check-decoded-url")) @@ -1171,6 +1188,11 @@ struct http_response *redirect_url(struct client_state *csp) q = p++; } } + else + { + /* All redirection actions are disabled */ + return NULL; + } /* * if there was any, generate and return a HTTP redirect */ @@ -1390,7 +1412,7 @@ int is_untrusted_url(struct client_state *csp) char *pcrs_filter_response(struct client_state *csp) { int hits=0; - size_t size; + size_t size, prev_size; char *old = csp->iob->cur, *new = NULL; pcrs_job *job; @@ -1472,9 +1494,7 @@ char *pcrs_filter_response(struct client_state *csp) continue; } - log_error(LOG_LEVEL_RE_FILTER, "re_filtering %s%s (size %d) with filter %s...", - csp->http->hostport, csp->http->path, size, b->name); - + prev_size = size; /* Apply all jobs from the joblist */ for (job = b->joblist; NULL != job; job = job->next) { @@ -1483,7 +1503,9 @@ char *pcrs_filter_response(struct client_state *csp) old=new; } - log_error(LOG_LEVEL_RE_FILTER, " ...produced %d hits (new size %d).", current_hits, size); + log_error(LOG_LEVEL_RE_FILTER, "re_filtering %s%s (size %d) with filter %s produced %d hits (new size %d).", + csp->http->hostport, csp->http->path, prev_size, b->name, current_hits, size); + hits += current_hits; } }