X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=filters.c;h=0192314c63e1e823ee72fb06246744d18d929f03;hb=669e2ba1bd80ffbc68897ace3a8547140c7e9805;hp=3586be0bc618e8bce0862b9aaa3ccc731e8d4b27;hpb=8eb4a58566a5aa38aa94f372a3fdeed87bcef2f2;p=privoxy.git diff --git a/filters.c b/filters.c index 3586be0b..0192314c 100644 --- a/filters.c +++ b/filters.c @@ -1,4 +1,4 @@ -const char filters_rcs[] = "$Id: filters.c,v 1.17 2001/06/09 10:55:28 jongfoster Exp $"; +const char filters_rcs[] = "$Id: filters.c,v 1.19 2001/06/29 21:45:41 oes Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/filters.c,v $ @@ -38,6 +38,35 @@ const char filters_rcs[] = "$Id: filters.c,v 1.17 2001/06/09 10:55:28 jongfoster * * Revisions : * $Log: filters.c,v $ + * Revision 1.19 2001/06/29 21:45:41 oes + * Indentation, CRLF->LF, Tab-> Space + * + * Revision 1.18 2001/06/29 13:27:38 oes + * - Cleaned up, renamed and reorderd functions + * and improved comments + * + * - block_url: + * - Ported to CGI platform. Now delivers + * http_response or NULL + * - Unified HTML and GIF generation (moved image detection + * and GIF generation here from jcc.c:chat()) + * - Fixed HTTP status to: + * - 403 (Forbidden) for the "blocked" HTML message + * - 200 (OK) for GIF answers + * - 302 (Redirect) for redirect to GIF + * + * - trust_url: + * - Ported to CGI platform. Now delivers + * http_response or NULL + * - Separated detection of untrusted URL into + * (bool)is_untrusted_url + * - Added enforcement of untrusted requests + * + * - Moved redirect_url() from cgi.c to here + * and ported it to the CGI platform + * + * - Removed logentry from cancelled commit + * * Revision 1.17 2001/06/09 10:55:28 jongfoster * Changing BUFSIZ ==> BUFFER_SIZE * @@ -251,8 +280,7 @@ const char filters_h_rcs[] = FILTERS_H_VERSION; * Returns : 0 = FALSE (don't block) and 1 = TRUE (do block) * *********************************************************************/ -int block_acl(struct access_control_addr *dst, - struct client_state *csp) +int block_acl(struct access_control_addr *dst, struct client_state *csp) { struct access_control_list *acl = csp->config->acl; @@ -387,7 +415,7 @@ int acl_addr(char *aspec, struct access_control_addr *aca) struct http_response *block_url(struct client_state *csp) { char *p; - struct http_response *rsp; + struct http_response *rsp; struct map *exports = NULL; /* @@ -411,10 +439,10 @@ struct http_response *block_url(struct client_state *csp) * as specified by the relevant +image action */ #ifdef IMAGE_BLOCKING - if (((csp->action->flags & ACTION_IMAGE_BLOCKER) != 0) + if (((csp->action->flags & ACTION_IMAGE_BLOCKER) != 0) && is_imageurl(csp)) - { - /* determine HOW images should be blocked */ + { + /* determine HOW images should be blocked */ p = csp->action->string[ACTION_STRING_IMAGE_BLOCKER]; /* and handle accordingly: */ @@ -446,7 +474,7 @@ struct http_response *block_url(struct client_state *csp) */ { - exports = default_exports(csp, NULL); + exports = default_exports(csp, NULL); #ifdef FORCE_LOAD exports = map(exports, "force-prefix", 1, FORCE_PREFIX, 1); #else @@ -495,7 +523,7 @@ struct http_response *trust_url(struct client_state *csp) */ if (!is_untrusted_url(csp)) { - return NULL; + return NULL; } /* @@ -509,7 +537,7 @@ struct http_response *trust_url(struct client_state *csp) /* * Export the host, port, and referrer information - */ + */ exports = map(exports, "hostport", 1, csp->http->hostport, 1); exports = map(exports, "path", 1, csp->http->path, 1); exports = map(exports, "hostport-html", 1, html_encode(csp->http->hostport), 0); @@ -546,25 +574,23 @@ struct http_response *trust_url(struct client_state *csp) for (l = csp->config->trust_info->next; l ; l = l->next) { - sprintf(buf, - "
  • %s
    \n", - l->str, l->str); + sprintf(buf, "
  • %s
    \n",l->str, l->str); p = strsav(p, buf); } exports = map(exports, "trust-info", 1, p, 0); } else - { - exports = map_block_killer(exports, "have-trust-info"); - } + { + exports = map_block_killer(exports, "have-trust-info"); + } /* * Export the force prefix or the force conditional block killer */ #ifdef FORCE_LOAD - exports = map(exports, "force-prefix", 1, FORCE_PREFIX, 1); + exports = map(exports, "force-prefix", 1, FORCE_PREFIX, 1); #else - exports = map_block_killer(exports, "force-support"); + exports = map_block_killer(exports, "force-support"); #endif /* ndef FORCE_LOAD */ /* @@ -701,11 +727,18 @@ int is_untrusted_url(struct client_state *csp) struct http_request rhttp[1]; char *p, *h; + /* + * If we don't have a trustlist, we trust everybody + */ if (((fl = csp->tlist) == NULL) || ((b = fl->f) == NULL)) { return(0); } + + /* + * Do we trust the request URL itself? + */ *url = dsplit(csp->http->host); /* if splitting the domain fails, punt */ @@ -744,7 +777,7 @@ int is_untrusted_url(struct client_state *csp) if ((csp->referrer == NULL)|| (strlen(csp->referrer) <= 9)) { /* no referrer was supplied */ - return(1); + return(1); } /* forge a URL from the referrer so we can use @@ -764,6 +797,10 @@ int is_untrusted_url(struct client_state *csp) return(1); } + + /* + * If not, do we maybe trust its referrer? + */ *url = dsplit(rhttp->host); /* if splitting the domain fails, punt */ @@ -824,7 +861,7 @@ int is_untrusted_url(struct client_state *csp) } } } - + return(1); } #endif /* def TRUST_FILES */ @@ -919,6 +956,7 @@ void url_actions(struct http_request *http, } apply_url_actions(csp->action, http, b); + } @@ -1069,12 +1107,13 @@ struct url_spec dsplit(char *domain) if (domain[strlen(domain) - 1] == '.') { - ret->unanchored |= ANCHOR_RIGHT; - } - if (domain[0] == '.') + ret->unanchored |= ANCHOR_RIGHT; + } + + if (domain[0] == '.') { - ret->unanchored |= ANCHOR_LEFT; - } + ret->unanchored |= ANCHOR_LEFT; + } ret->dbuf = strdup(domain); @@ -1098,7 +1137,6 @@ struct url_spec dsplit(char *domain) memcpy(ret->dvec, v, size); } - return(*ret); } @@ -1136,6 +1174,7 @@ static int simple_domaincmp(char **pv, char **fv, int len) } return 0; + } @@ -1218,8 +1257,8 @@ int domaincmp(struct url_spec *pattern, struct url_spec *fqdn) } return 1; } -} +} /*