X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=filters.c;h=42f46aff89d41c957bd51a6743dde13f60f260f3;hp=29cee4788a9b1f77688c0cb80d33b8020b7dcf63;hb=f26b39e9b1a98bb4822eded2995c886effbfab04;hpb=c75584ebcc79f939fb4ec9c8f842cef6692640c7 diff --git a/filters.c b/filters.c index 29cee478..42f46aff 100644 --- a/filters.c +++ b/filters.c @@ -1,15 +1,15 @@ -const char filters_rcs[] = "$Id: filters.c,v 1.1 2001/05/13 21:57:06 administrator Exp $"; +const char filters_rcs[] = "$Id: filters.c,v 1.3 2001/05/20 16:44:47 jongfoster Exp $"; /********************************************************************* * - * File : $Source: /home/administrator/cvs/ijb/filters.c,v $ + * File : $Source: /cvsroot/ijbswa/current/filters.c,v $ * * Purpose : Declares functions to parse/crunch headers and pages. * Functions declared include: * `acl_addr', `add_stats', `block_acl', `block_imageurl', - * `block_url', `cookie_url', `domaincmp', `dsplit', - * `filter_popups', `forward_url', + * `block_url', `url_permissions', `domaincmp', `dsplit', + * `filter_popups', `forward_url', 'redirect_url', * `ij_untrusted_url', `intercept_url', `re_process_buffer', - * `show_proxy_args', and `trust_url' + * `show_proxy_args', 'ijb_send_banner', and `trust_url' * * Copyright : Written by and Copyright (C) 2001 the SourceForge * IJBSWA team. http://ijbswa.sourceforge.net @@ -38,6 +38,25 @@ const char filters_rcs[] = "$Id: filters.c,v 1.1 2001/05/13 21:57:06 administrat * * Revisions : * $Log: filters.c,v $ + * Revision 1.3 2001/05/20 16:44:47 jongfoster + * Removing last hardcoded JunkBusters.com URLs. + * + * Revision 1.2 2001/05/20 01:21:20 jongfoster + * Version 2.9.4 checkin. + * - Merged popupfile and cookiefile, and added control over PCRS + * filtering, in new "permissionsfile". + * - Implemented LOG_LEVEL_FATAL, so that if there is a configuration + * file error you now get a message box (in the Win32 GUI) rather + * than the program exiting with no explanation. + * - Made killpopup use the PCRS MIME-type checking and HTTP-header + * skipping. + * - Removed tabs from "config" + * - Moved duplicated url parsing code in "loaders.c" to a new funcition. + * - Bumped up version number. + * + * Revision 1.1.1.1 2001/05/15 13:58:52 oes + * Initial import of version 2.9.3 source tree + * * *********************************************************************/ @@ -107,8 +126,8 @@ static const char CBLOCK[] = "was blocked because it matches the following pattern " "in the blockfile: %s\n

" #ifdef FORCE_LOAD - "

Go there anyway.

" + "

Go there anyway.

" #endif /* def FORCE_LOAD */ "\n" "\n"; @@ -494,7 +513,10 @@ void re_process_buffer(struct client_state *csp) struct re_filterfile_spec *b; /* Sanity first ;-) */ - if (size <= 0) return; + if (size <= 0) + { + return; + } if ( ( NULL == (fl = csp->rlist) ) || ( NULL == (b = fl->f) ) ) { @@ -505,7 +527,7 @@ void re_process_buffer(struct client_state *csp) joblist = b->joblist; - log_error(LOG_LEVEL_REF, "re_filtering %s%s (size %d) ...", + log_error(LOG_LEVEL_RE_FILTER, "re_filtering %s%s (size %d) ...", csp->http->hostport, csp->http->path, size); /* Apply all jobs from the joblist */ @@ -516,7 +538,7 @@ void re_process_buffer(struct client_state *csp) old=new; } - log_error(LOG_LEVEL_REF, " produced %d hits (new size %d).", hits, size); + log_error(LOG_LEVEL_RE_FILTER, " produced %d hits (new size %d).", hits, size); if (write_socket(csp->cfd, old, size) != size) { @@ -786,35 +808,83 @@ char *intercept_url(struct http_request *http, struct client_state *csp) } +#ifdef FAST_REDIRECTS +/********************************************************************* + * + * Function : redirect_url + * + * Description : Checks for redirection URLs and returns a HTTP redirect + * to the destination URL. + * + * Parameters : + * 1 : http = http_request request, check `basename's of blocklist + * 2 : csp = Current client state (buffers, headers, etc...) + * + * Returns : NULL if URL was clean, HTTP redirect otherwise. + * + *********************************************************************/ +char *redirect_url(struct http_request *http, struct client_state *csp) +{ + char *p, *q; + + p = q = csp->http->path; + log_error(LOG_LEVEL_REDIRECTS, "checking path: %s", p); + + /* find the last URL encoded in the request */ + while (p = strstr(p, "http://")) + { + q = p++; + } + + /* if there was any, generate and return a HTTP redirect */ + if (q != csp->http->path) + { + log_error(LOG_LEVEL_REDIRECTS, "redirecting to: %s", q); + + p = (char *)malloc(strlen(HTTP_REDIRECT_TEMPLATE) + strlen(q)); + sprintf(p, HTTP_REDIRECT_TEMPLATE, q); + return(p); + } + else + { + return(NULL); + } + +} +#endif /* def FAST_REDIRECTS */ /********************************************************************* * - * Function : cookie_url + * Function : url_permissions * - * Description : Accept this cookie, or no? See "cookiefile" setting. + * Description : Gets the permissions for this URL. * * Parameters : * 1 : http = http_request request for blocked URLs * 2 : csp = Current client state (buffers, headers, etc...) * - * Returns : NULL => accept, cookie_spec pointer to crunch. + * Returns : permissions bitmask specifiying what this URL can do. + * If not on list, will be default_permissions. * *********************************************************************/ -struct cookie_spec *cookie_url(struct http_request *http, struct client_state *csp) +int url_permissions(struct http_request *http, struct client_state *csp) { struct file_list *fl; - struct cookie_spec *b; + struct permissions_spec *b; struct url_spec url[1]; - if (((fl = csp->clist) == NULL) || ((b = fl->f) == NULL)) + if (((fl = csp->permissions_list) == NULL) || ((b = fl->f) == NULL)) { - return(NULL); + return(default_permissions); } *url = dsplit(http->host); /* if splitting the domain fails, punt */ - if (url->dbuf == NULL) return(NULL); + if (url->dbuf == NULL) + { + return(default_permissions); + } for (b = b->next; NULL != b; b = b->next) { @@ -832,7 +902,7 @@ struct cookie_spec *cookie_url(struct http_request *http, struct client_state *c { freez(url->dbuf); freez(url->dvec); - return(b); + return(b->permissions); } } } @@ -840,7 +910,7 @@ struct cookie_spec *cookie_url(struct http_request *http, struct client_state *c freez(url->dbuf); freez(url->dvec); - return(NULL); + return(default_permissions); } @@ -1055,11 +1125,11 @@ char *show_proxy_args(struct http_request *http, struct client_state *csp) file_description = "Block List"; } break; - case 'c': - if (csp->clist) + case 'p': + if (csp->permissions_list) { - filename = csp->clist->filename; - file_description = "Cookie List"; + filename = csp->permissions_list->filename; + file_description = "Permissions List"; } break; case 'f': @@ -1090,16 +1160,6 @@ char *show_proxy_args(struct http_request *http, struct client_state *csp) break; #endif /* def USE_IMAGE_LIST */ -#ifdef KILLPOPUPS - case 'p': - if (csp->plist) - { - filename = csp->plist->filename; - file_description = "Popup list"; - } - break; -#endif /* def KILLPOPUPS */ - #ifdef PCRS case 'r': if (csp->rlist) @@ -1186,17 +1246,9 @@ char *show_proxy_args(struct http_request *http, struct client_state *csp) "

Back to proxy status

\n" "
\n" "

\n" - "Code and documentation of the " BANNER " Proxy" - "TM\n" - "\n" "Copyright© 1997 Junkbusters Corporation\n" - "TM
\n" - "Copying and distribution permitted under the" - "\n" - "GNU " - "General Public License.\n" - "
" - "

webmaster@junkbusters.com
" - "
" + "The " BANNER " Proxy - \n" + "" HOME_PAGE_URL "\n" + "" "\n"); return(s); } @@ -1222,10 +1274,10 @@ char *show_proxy_args(struct http_request *http, struct client_state *csp) s = strsav(s, "\n"); } - if (csp->clist) + if (csp->permissions_list) { - s = strsav(s, "
  • Cookie List: "); - s = strsav(s, csp->clist->filename); + s = strsav(s, "
  • Permissions List: "); + s = strsav(s, csp->permissions_list->filename); s = strsav(s, "
  • \n"); } @@ -1254,15 +1306,6 @@ char *show_proxy_args(struct http_request *http, struct client_state *csp) } #endif /* def USE_IMAGE_LIST */ -#ifdef KILLPOPUPS - if (csp->plist) - { - s = strsav(s, "
  • Popup List: "); - s = strsav(s, csp->plist->filename); - s = strsav(s, "
  • \n"); - } -#endif /* def KILLPOPUPS */ - #ifdef PCRS if (csp->rlist) { @@ -1313,13 +1356,6 @@ char *show_proxy_args(struct http_request *http, struct client_state *csp) } #endif /* def USE_IMAGE_LIST */ -#ifdef KILLPOPUPS - if (csp->plist) - { - s = strsav(s, csp->plist->proxy_args); - } -#endif /* def KILLPOPUPS */ - #ifdef PCRS if (csp->rlist) { @@ -1343,6 +1379,28 @@ char *show_proxy_args(struct http_request *http, struct client_state *csp) } +/********************************************************************* + * + * Function : ijb_send_banner + * + * Description : This "crunch"es "http:/any.thing/ijb-send-banner and + * thus triggers sending the image in jcc.c:chat. + * For the unlikely case, that the imagefile/MSIE + * mechanism is not used, or tinygif = 0, a page + * describing the reson of the interception is generated. + * + * Parameters : + * 1 : http = http_request request for crunched URL + * 2 : csp = Current client state (buffers, headers, etc...) + * + * Returns : A string that contains why this was intercepted. + * + *********************************************************************/ +char *ijb_send_banner(struct http_request *http, struct client_state *csp) +{ + return(strdup(CNOBANNER)); +} + #ifdef TRUST_FILES /********************************************************************* *