X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=filters.c;h=cff05c4a9bf24d3dc8aacc0531c4b31721aba4e9;hb=91f8d1cfa59b145296b7b5dc4ee07bdb32517b8b;hp=065a2f9b90726bfa1466e9845e7d1a40d15e9352;hpb=3fae4c0f831bf0d681a20ab55e1d082d24cf5522;p=privoxy.git diff --git a/filters.c b/filters.c index 065a2f9b..cff05c4a 100644 --- a/filters.c +++ b/filters.c @@ -1,4 +1,4 @@ -const char filters_rcs[] = "$Id: filters.c,v 1.41 2001/11/13 00:14:07 jongfoster Exp $"; +const char filters_rcs[] = "$Id: filters.c,v 1.53 2002/03/26 22:29:54 swa Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/filters.c,v $ @@ -12,7 +12,7 @@ const char filters_rcs[] = "$Id: filters.c,v 1.41 2001/11/13 00:14:07 jongfoster * 'ijb_send_banner', and `trust_url' * * Copyright : Written by and Copyright (C) 2001 the SourceForge - * IJBSWA team. http://ijbswa.sourceforge.net + * Privoxy team. http://www.privoxy.org/ * * Based on the Internet Junkbuster originally written * by and Copyright (C) 1997 Anonymous Coders and @@ -38,6 +38,60 @@ const char filters_rcs[] = "$Id: filters.c,v 1.41 2001/11/13 00:14:07 jongfoster * * Revisions : * $Log: filters.c,v $ + * Revision 1.53 2002/03/26 22:29:54 swa + * we have a new homepage! + * + * Revision 1.52 2002/03/24 16:35:57 jongfoster + * Removing logo + * + * Revision 1.51 2002/03/24 15:23:33 jongfoster + * Name changes + * + * Revision 1.50 2002/03/24 13:25:43 swa + * name change related issues + * + * Revision 1.49 2002/03/16 20:29:14 oes + * Cosmetics + * + * Revision 1.48 2002/03/13 20:25:34 oes + * Better logging for content filters + * + * Revision 1.47 2002/03/13 00:30:52 jongfoster + * Killing warnings + * Added option of always sending redirect for imageblock, + * currently disabled with #if 0. + * + * Revision 1.46 2002/03/12 01:42:49 oes + * Introduced modular filters + * + * Revision 1.45 2002/03/08 16:47:50 oes + * Added choice beween GIF and PNG built-in images + * + * Revision 1.44 2002/03/07 03:49:31 oes + * - Fixed compiler warnings etc + * - Changed built-in images from GIF to PNG + * (with regard to Unisys patent issue) + * - Added a 4x4 pattern PNG which is less intrusive + * than the logo but also clearly marks the deleted banners + * + * Revision 1.43 2002/01/22 23:51:59 jongfoster + * Replacing strsav() with the safer string_append(). + * + * Adding missing html_encode() to error message generators. Where encoded + * and unencoded versions of a string were provided, removing the unencoded + * one. + * + * Revision 1.42 2002/01/17 21:00:32 jongfoster + * Moving all our URL and URL pattern parsing code to urlmatch.c. + * + * Using a single, simple url_match(pattern,url) function - rather than + * the 3-line match routine which was repeated all over the place. + * + * Renaming free_url to free_url_spec, since it frees a struct url_spec. + * + * Using parse_http_url() to parse URLs without faking a HTTP + * request line for parse_http_request(). + * * Revision 1.41 2001/11/13 00:14:07 jongfoster * Fixing stupid bug now I've figured out what || means. * (It always returns 0 or 1, not one of it's paramaters.) @@ -445,7 +499,7 @@ int block_acl(struct access_control_addr *dst, struct client_state *csp) * * Function : acl_addr * - * Description : Called from `load_aclfile' to parse an ACL address. + * Description : Called from `load_config' to parse an ACL address. * * Parameters : * 1 : aspec = String specifying ACL address. @@ -462,7 +516,7 @@ int acl_addr(char *aspec, struct access_control_addr *aca) masklength = 32; port = 0; - if ((p = strchr(aspec, '/'))) + if ((p = strchr(aspec, '/')) != NULL) { *p++ = '\0'; @@ -478,7 +532,7 @@ int acl_addr(char *aspec, struct access_control_addr *aca) return(-1); } - if ((p = strchr(aspec, ':'))) + if ((p = strchr(aspec, ':')) != NULL) { *p++ = '\0'; @@ -493,9 +547,8 @@ int acl_addr(char *aspec, struct access_control_addr *aca) aca->addr = ntohl(resolve_hostname_to_ip(aspec)); - if (aca->addr == -1) + if (aca->addr == INADDR_NONE) { - log_error(LOG_LEVEL_ERROR, "can't resolve address for %s", aspec); return(-1); } @@ -643,18 +696,20 @@ struct http_response *block_url(struct client_state *csp) /* determine HOW images should be blocked */ p = csp->action->string[ACTION_STRING_IMAGE_BLOCKER]; +#if 1 /* Two alternative strategies, use this one for now: */ + /* and handle accordingly: */ - if ((p == NULL) || (0 == strcmpic(p, "logo"))) + if ((p == NULL) || (0 == strcmpic(p, "pattern"))) { - rsp->body = bindup(image_junkbuster_gif_data, image_junkbuster_gif_length); + rsp->body = bindup(image_pattern_data, image_pattern_length); if (rsp->body == NULL) { free_http_response(rsp); return cgi_error_memory(); } - rsp->content_length = image_junkbuster_gif_length; + rsp->content_length = image_pattern_length; - if (enlist_unique_header(rsp->headers, "Content-Type", "image/gif")) + if (enlist_unique_header(rsp->headers, "Content-Type", BUILTIN_IMAGE_MIMETYPE)) { free_http_response(rsp); return cgi_error_memory(); @@ -663,15 +718,15 @@ struct http_response *block_url(struct client_state *csp) else if (0 == strcmpic(p, "blank")) { - rsp->body = bindup(image_blank_gif_data, image_blank_gif_length); + rsp->body = bindup(image_blank_data, image_blank_length); if (rsp->body == NULL) { free_http_response(rsp); return cgi_error_memory(); } - rsp->content_length = image_blank_gif_length; + rsp->content_length = image_blank_length; - if (enlist_unique_header(rsp->headers, "Content-Type", "image/gif")) + if (enlist_unique_header(rsp->headers, "Content-Type", BUILTIN_IMAGE_MIMETYPE)) { free_http_response(rsp); return cgi_error_memory(); @@ -680,7 +735,7 @@ struct http_response *block_url(struct client_state *csp) else { - rsp->status = strdup("302 Local Redirect from Junkbuster"); + rsp->status = strdup("302 Local Redirect from Privoxy"); if (rsp->status == NULL) { free_http_response(rsp); @@ -693,6 +748,31 @@ struct http_response *block_url(struct client_state *csp) return cgi_error_memory(); } } + +#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 */ @@ -817,18 +897,14 @@ struct http_response *trust_url(struct client_state *csp) */ err = map(exports, "hostport", 1, csp->http->hostport, 1); if (!err) err = map(exports, "path", 1, csp->http->path, 1); - if (!err) err = map(exports, "hostport-html", 1, html_encode(csp->http->hostport), 0); - if (!err) err = map(exports, "path-html", 1, html_encode(csp->http->path), 0); if (NULL != (p = get_header_value(csp->headers, "Referer:"))) { - if (!err) err = map(exports, "referrer", 1, p, 1); - if (!err) err = map(exports, "referrer-html", 1, html_encode(p), 0); + if (!err) err = map(exports, "referrer", 1, html_encode(p), 0); } else { if (!err) err = map(exports, "referrer", 1, "unknown", 1); - if (!err) err = map(exports, "referrer-html", 1, "unknown", 1); } if (err) @@ -842,7 +918,7 @@ struct http_response *trust_url(struct client_state *csp) * Export the trust list */ p = strdup(""); - for (tl = csp->config->trust_list; (t = *tl) ; tl++) + for (tl = csp->config->trust_list; (t = *tl) != NULL ; tl++) { sprintf(buf, "