-const char filters_rcs[] = "$Id: filters.c,v 1.45 2002/03/08 16:47:50 oes Exp $";
+const char filters_rcs[] = "$Id: filters.c,v 1.49 2002/03/16 20:29:14 oes Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/filters.c,v $
* 'ijb_send_banner', and `trust_url'
*
* Copyright : Written by and Copyright (C) 2001 the SourceForge
- * IJBSWA team. http://ijbswa.sourceforge.net
+ * Privoxy team. http://ijbswa.sourceforge.net
*
* Based on the Internet Junkbuster originally written
* by and Copyright (C) 1997 Anonymous Coders and
*
* Revisions :
* $Log: filters.c,v $
+ * 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
*
masklength = 32;
port = 0;
- if ((p = strchr(aspec, '/')))
+ if ((p = strchr(aspec, '/')) != NULL)
{
*p++ = '\0';
return(-1);
}
- if ((p = strchr(aspec, ':')))
+ if ((p = strchr(aspec, ':')) != NULL)
{
*p++ = '\0';
/* 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")))
{
return cgi_error_memory();
}
}
+
+#else /* Following code is disabled for now */
+
+ /* and handle accordingly: */
+ if ((p == NULL) || (0 == strcmpic(p, "logo")))
+ {
+ p = CGI_PREFIX "send-banner?type=logo";
+ }
+ else if (0 == strcmpic(p, "blank"))
+ {
+ p = CGI_PREFIX "send-banner?type=blank";
+ }
+ else if (0 == strcmpic(p, "pattern"))
+ {
+ p = CGI_PREFIX "send-banner?type=pattern";
+ }
+ rsp->status = strdup("302 Local Redirect from Junkbuster");
+ 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 */
* 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, "<li>%s</li>\n", t->spec);
string_append(&p, buf);
/*
* find the last URL encoded in the request
*/
- while ((p = strstr(p, "http://")))
+ while ((p = strstr(p, "http://")) != NULL)
{
q = p++;
}
FILE *fp;
- if ((fp = fopen(csp->config->trustfile, "a")))
+ if (NULL != (fp = fopen(csp->config->trustfile, "a")))
{
char * path;
char * path_end;
for (filtername = csp->action->multi[ACTION_MULTI_FILTER]->first;
filtername ; filtername = filtername->next)
{
- if (strcmp(b->filtername, filtername->str) == 0)
+ if (strcmp(b->name, filtername->str) == 0)
{
+ int current_hits = 0;
+
if ( NULL == b->joblist )
{
- log_error(LOG_LEVEL_RE_FILTER, "Filter %s has empty joblist. Nothing to do.", b->filtername);
+ log_error(LOG_LEVEL_RE_FILTER, "Filter %s has empty joblist. Nothing to do.", b->name);
return(NULL);
}
log_error(LOG_LEVEL_RE_FILTER, "re_filtering %s%s (size %d) with filter %s...",
- csp->http->hostport, csp->http->path, size, b->filtername);
+ csp->http->hostport, csp->http->path, size, b->name);
/* Apply all jobs from the joblist */
for (job = b->joblist; NULL != job; job = job->next)
{
- hits += pcrs_execute(job, old, size, &new, &size);
+ current_hits += pcrs_execute(job, old, size, &new, &size);
if (old != csp->iob->cur) free(old);
old=new;
}
- log_error(LOG_LEVEL_RE_FILTER, " ...produced %d hits (new size %d).", hits, size);
+ log_error(LOG_LEVEL_RE_FILTER, " ...produced %d hits (new size %d).", current_hits, size);
+ hits += current_hits;
}
}
}
}
else
{
- log_error(LOG_LEVEL_DEANIMATE, "Success! GIF shrunk from %d bytes to %d.", size, out->offset);
+ if ((int)size == out->offset)
+ {
+ log_error(LOG_LEVEL_DEANIMATE, "GIF not changed.");
+ }
+ else
+ {
+ log_error(LOG_LEVEL_DEANIMATE, "Success! GIF shrunk from %d bytes to %d.", size, out->offset);
+ }
csp->content_length = out->offset;
csp->flags |= CSP_FLAG_MODIFIED;
p = out->buffer;