-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 $
*
* 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
*
* 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;
struct http_response *block_url(struct client_state *csp)
{
char *p;
- struct http_response *rsp;
+ struct http_response *rsp;
struct map *exports = NULL;
/*
* 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: */
*/
{
- exports = default_exports(csp, NULL);
+ exports = default_exports(csp, NULL);
#ifdef FORCE_LOAD
exports = map(exports, "force-prefix", 1, FORCE_PREFIX, 1);
#else
*/
if (!is_untrusted_url(csp))
{
- return NULL;
+ return NULL;
}
/*
/*
* 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);
for (l = csp->config->trust_info->next; l ; l = l->next)
{
- sprintf(buf,
- "<li> <a href=%s>%s</a><br>\n",
- l->str, l->str);
+ sprintf(buf, "<li> <a href=%s>%s</a><br>\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 */
/*
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 */
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
return(1);
}
+
+ /*
+ * If not, do we maybe trust its referrer?
+ */
*url = dsplit(rhttp->host);
/* if splitting the domain fails, punt */
}
}
}
-
+ return(1);
}
#endif /* def TRUST_FILES */
}
apply_url_actions(csp->action, http, b);
+
}
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);
memcpy(ret->dvec, v, size);
}
-
return(*ret);
}
}
return 0;
+
}
}
return 1;
}
-}
+}
/*