X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=filters.c;h=f3b31bb5eaf0e93b42d1be904077209a78777285;hp=219c58184f414a3c83e4128c1c8c98deef27a5f3;hb=b733510949271dffd1c1b925281eaa3e4af7992f;hpb=40f23d485c1e8bc8aa892b93d644dad4b8243685 diff --git a/filters.c b/filters.c index 219c5818..f3b31bb5 100644 --- a/filters.c +++ b/filters.c @@ -1,4 +1,4 @@ -const char filters_rcs[] = "$Id: filters.c,v 1.124 2009/08/19 15:24:30 fabiankeil Exp $"; +const char filters_rcs[] = "$Id: filters.c,v 1.128 2010/04/03 13:23:28 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/filters.c,v $ @@ -13,7 +13,7 @@ const char filters_rcs[] = "$Id: filters.c,v 1.124 2009/08/19 15:24:30 fabiankei * `execute_single_pcrs_command', `rewrite_url', * `get_last_url' * - * Copyright : Written by and Copyright (C) 2001, 2004-2009 the + * Copyright : Written by and Copyright (C) 2001-2010 the * Privoxy team. http://www.privoxy.org/ * * Based on the Internet Junkbuster originally written @@ -599,7 +599,6 @@ struct http_response *block_url(struct client_state *csp) { log_error(LOG_LEVEL_ERROR, "handle-as-empty-document overruled by handle-as-image."); } -#if 1 /* Two alternative strategies, use this one for now: */ /* and handle accordingly: */ if ((p == NULL) || (0 == strcmpic(p, "pattern"))) @@ -624,7 +623,6 @@ struct http_response *block_url(struct client_state *csp) return cgi_error_memory(); } } - else if (0 == strcmpic(p, "blank")) { rsp->status = strdup("403 Request blocked by Privoxy"); @@ -647,7 +645,6 @@ struct http_response *block_url(struct client_state *csp) return cgi_error_memory(); } } - else { rsp->status = strdup("302 Local Redirect from Privoxy"); @@ -664,30 +661,6 @@ struct http_response *block_url(struct client_state *csp) } } -#else /* Following code is disabled for now */ - - /* and handle accordingly: */ - if ((p == NULL) || (0 == strcmpic(p, "pattern"))) - { - p = CGI_PREFIX "send-banner?type=pattern"; - } - else if (0 == strcmpic(p, "blank")) - { - p = CGI_PREFIX "send-banner?type=blank"; - } - rsp->status = strdup("302 Local Redirect from Privoxy"); - if (rsp->status == NULL) - { - free_http_response(rsp); - return cgi_error_memory(); - } - - if (enlist_unique_header(rsp->headers, "Location", p)) - { - free_http_response(rsp); - return cgi_error_memory(); - } -#endif /* Preceeding code is disabled for now */ } else #endif /* def FEATURE_IMAGE_BLOCKING */ @@ -702,7 +675,21 @@ struct http_response *block_url(struct client_state *csp) rsp->body = strdup(" "); rsp->content_length = 1; - rsp->status = strdup("403 Request blocked by Privoxy"); + if (csp->config->feature_flags & RUNTIME_FEATURE_EMPTY_DOC_RETURNS_OK) + { + /* + * Workaround for firefox bug 492459 + * https://bugzilla.mozilla.org/show_bug.cgi?id=492459 + * Return a 200 OK status for pages blocked with +handle-as-empty-document + * if the "handle-as-empty-doc-returns-ok" runtime config option is set. + */ + rsp->status = strdup("200 Request blocked by Privoxy"); + } + else + { + rsp->status = strdup("403 Request blocked by Privoxy"); + } + if (rsp->status == NULL) { free_http_response(rsp); @@ -1523,7 +1510,8 @@ int is_untrusted_url(const struct client_state *csp) *********************************************************************/ static char *pcrs_filter_response(struct client_state *csp) { - int hits=0; + int hits = 0; + int i; size_t size, prev_size; char *old = NULL; @@ -1534,8 +1522,6 @@ static char *pcrs_filter_response(struct client_state *csp) struct re_filterfile_spec *b; struct list_entry *filtername; - int i, found_filters = 0; - /* * Sanity first */ @@ -1544,23 +1530,7 @@ static char *pcrs_filter_response(struct client_state *csp) return(NULL); } - /* - * Need to check the set of re_filterfiles... - */ - for (i = 0; i < MAX_AF_FILES; i++) - { - fl = csp->rlist[i]; - if (NULL != fl) - { - if (NULL != fl->f) - { - found_filters = 1; - break; - } - } - } - - if (0 == found_filters) + if (filters_available(csp) == FALSE) { log_error(LOG_LEVEL_ERROR, "Inconsistent configuration: " "content filtering enabled, but no content filters available."); @@ -2350,6 +2320,34 @@ int content_filters_enabled(const struct current_action_spec *action) !list_is_empty(action->multi[ACTION_MULTI_FILTER])); } + +/********************************************************************* + * + * Function : filters_available + * + * Description : Checks whether there are any filters available. + * + * Parameters : + * 1 : csp = Current client state (buffers, headers, etc...) + * + * Returns : TRUE for yes, FALSE otherwise. + * + *********************************************************************/ +int filters_available(const struct client_state *csp) +{ + int i; + for (i = 0; i < MAX_AF_FILES; i++) + { + const struct file_list *fl = csp->rlist[i]; + if ((NULL != fl) && (NULL != fl->f)) + { + return TRUE; + } + } + return FALSE; +} + + /* Local Variables: tab-width: 3