X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=filters.c;h=309aca3fd7b546b44a2989c3df6970d4c3a97bfe;hp=dd7ccb4409680751b223dd97049d571a0985bf65;hb=1d9d93f0fca5cfc677f435c460dd6f271a8f087f;hpb=5f390b415777db21894f1b856ab3d21c9c24f7c6 diff --git a/filters.c b/filters.c index dd7ccb44..309aca3f 100644 --- a/filters.c +++ b/filters.c @@ -1,4 +1,4 @@ -const char filters_rcs[] = "$Id: filters.c,v 1.38 2001/10/23 21:32:33 jongfoster Exp $"; +const char filters_rcs[] = "$Id: filters.c,v 1.40 2001/10/26 17:34:17 oes Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/filters.c,v $ @@ -38,6 +38,13 @@ const char filters_rcs[] = "$Id: filters.c,v 1.38 2001/10/23 21:32:33 jongfoster * * Revisions : * $Log: filters.c,v $ + * + * Revision 1.39 2001/10/25 03:40:48 david__schmidt + * Change in porting tactics: OS/2's EMX porting layer doesn't allow multiple + * threads to call select() simultaneously. So, it's time to do a real, live, + * native OS/2 port. See defines for __EMX__ (the porting layer) vs. __OS2__ + * (native). Both versions will work, but using __OS2__ offers multi-threading. + * * Revision 1.38 2001/10/23 21:32:33 jongfoster * Adding error-checking to selected functions * @@ -684,28 +691,17 @@ struct http_response *block_url(struct client_state *csp) jb_err err; struct map * exports; - /* FIXME */ -#ifdef __EMX__ - /* - * The entire OS/2 community will hit the stupid Netscape bug - * (all three of us! :-) so we'll just keep ourselves out - * of this contentious debate and special-case ourselves. - * The problem is... a this point in parsing, we don't know - * what the csp->http->user_agent is (yet). So we can't use - * it to decide if we should work around the NS bug or not. - */ - rsp->status = strdup("200 Request for blocked URL"); -#else /* * Workaround for stupid Netscape bug which prevents * pages from being displayed if loading a referenced * JavaScript or style sheet fails. So make it appear * as if it succeeded. */ - if (csp->http->user_agent - && !strncmpic(csp->http->user_agent, "mozilla", 7) - && !strstr(csp->http->user_agent, "compatible") - && !strstr(csp->http->user_agent, "Opera")) + if ( NULL != (p = get_header_value(csp->headers, "User-Agent:")) + && !strncmpic(p, "mozilla", 7) /* Catch Netscape but */ + && !strstr(p, "Gecko") /* save Mozilla, */ + && !strstr(p, "compatible") /* MSIE */ + && !strstr(p, "Opera")) /* and Opera. */ { rsp->status = strdup("200 Request for blocked URL"); } @@ -713,7 +709,7 @@ struct http_response *block_url(struct client_state *csp) { rsp->status = strdup("404 Request for blocked URL"); } -#endif /* __EMX__ */ + if (rsp->status == NULL) { free_http_response(rsp); @@ -813,10 +809,10 @@ struct http_response *trust_url(struct client_state *csp) || map(exports, "hostport-html", 1, html_encode(csp->http->hostport), 0) || map(exports, "path-html", 1, html_encode(csp->http->path), 0); - if (csp->referrer && strlen(csp->referrer) > 9) + if (NULL != (p = get_header_value(csp->headers, "Referer:"))) { - err = err || map(exports, "referrer", 1, csp->referrer + 9, 1); - err = err || map(exports, "referrer-html", 1, html_encode(csp->referrer + 9), 0); + err = err || map(exports, "referrer", 1, p, 1); + err = err || map(exports, "referrer-html", 1, html_encode(p), 0); } else { @@ -987,17 +983,23 @@ struct http_response *redirect_url(struct client_state *csp) int is_imageurl(struct client_state *csp) { #ifdef FEATURE_IMAGE_DETECT_MSIE - if ((csp->accept_types - & (ACCEPT_TYPE_IS_MSIE|ACCEPT_TYPE_MSIE_IMAGE|ACCEPT_TYPE_MSIE_HTML)) - == (ACCEPT_TYPE_IS_MSIE|ACCEPT_TYPE_MSIE_IMAGE)) - { - return 1; - } - else if ((csp->accept_types - & (ACCEPT_TYPE_IS_MSIE|ACCEPT_TYPE_MSIE_IMAGE|ACCEPT_TYPE_MSIE_HTML)) - == (ACCEPT_TYPE_IS_MSIE|ACCEPT_TYPE_MSIE_HTML)) + char *tmp; + + tmp = get_header_value(csp->headers, "User-Agent:"); + if (tmp && strstr(tmp, "MSIE")) { - return 0; + tmp = get_header_value(csp->headers, "Accept:"); + if (tmp && strstr(tmp, "image/gif")) + { + /* Client will accept HTML. If this seems counterintuitive, + * blame Microsoft. + */ + return(0); + } + else + { + return(1); + } } #endif /* def FEATURE_IMAGE_DETECT_MSIE */ @@ -1080,7 +1082,7 @@ int is_untrusted_url(struct client_state *csp) freez(url->dbuf); freez(url->dvec); - if ((csp->referrer == NULL)|| (strlen(csp->referrer) <= 9)) + if (NULL == (h = get_header_value(csp->headers, "Referer:"))) { /* no referrer was supplied */ return(1); @@ -1092,7 +1094,7 @@ int is_untrusted_url(struct client_state *csp) p = NULL; p = strsav(p, "GET "); - p = strsav(p, csp->referrer + 9); /* skip over "Referer: " */ + p = strsav(p, h); p = strsav(p, " HTTP/1.0"); parse_http_request(p, rhttp, csp);