*
* Revisions :
* $Log: actionlist.h,v $
+ * Revision 1.23 2006/10/09 10:26:18 fabiankeil
+ * Changed the path in set-image-blocker's redirection default to
+ * "send-banner?type=pattern" instead of "show-banner?type=pattern"
+ * which isn't caught by Privoxy. Fixes BR 1573468.
+ *
+ * Changed hide-user-agent's default value to "Privoxy VERSION".
+ *
+ * Changed hide-referrer's default fake value to "http://www.privoxy.org/".
+ * A static referrer is obviously fake anyway, so we might as well
+ * advertise ourselves.
+ *
* Revision 1.22 2006/09/01 17:14:18 hal9
* Re-ordered the actions list so that they display in the actions editor in
* alphabetical order. Some of the new actions were "out of order".
DEFINE_ACTION_MULTI ("add-header", ACTION_MULTI_ADD_HEADER)
DEFINE_ACTION_BOOL ("block", ACTION_BLOCK)
+DEFINE_ACTION_MULTI ("client-header-filter", ACTION_MULTI_CLIENT_HEADER_FILTER)
DEFINE_ACTION_STRING ("content-type-overwrite", ACTION_CONTENT_TYPE_OVERWRITE, ACTION_STRING_CONTENT_TYPE)
DEFINE_CGI_PARAM_NO_RADIO("content-type-overwrite", ACTION_CONTENT_TYPE_OVERWRITE, ACTION_STRING_CONTENT_TYPE, "text/html")
DEFINE_ACTION_STRING ("crunch-client-header", ACTION_CRUNCH_CLIENT_HEADER, ACTION_STRING_CLIENT_HEADER)
DEFINE_CGI_PARAM_RADIO ("fast-redirects", ACTION_FAST_REDIRECTS, ACTION_STRING_FAST_REDIRECTS, "simple-check", 0)
DEFINE_CGI_PARAM_RADIO ("fast-redirects", ACTION_FAST_REDIRECTS, ACTION_STRING_FAST_REDIRECTS, "check-decoded-url", 1)
DEFINE_ACTION_MULTI ("filter", ACTION_MULTI_FILTER)
-DEFINE_ACTION_BOOL ("filter-client-headers", ACTION_FILTER_CLIENT_HEADERS)
-DEFINE_ACTION_BOOL ("filter-server-headers", ACTION_FILTER_SERVER_HEADERS)
DEFINE_ACTION_BOOL ("force-text-mode", ACTION_FORCE_TEXT_MODE)
DEFINE_ACTION_BOOL ("handle-as-empty-document", ACTION_HANDLE_AS_EMPTY_DOCUMENT)
DEFINE_ACTION_BOOL ("handle-as-image", ACTION_IMAGE)
DEFINE_CGI_PARAM_NO_RADIO("redirect", ACTION_REDIRECT, ACTION_STRING_REDIRECT, "http://localhost/")
DEFINE_ACTION_BOOL ("send-vanilla-wafer", ACTION_VANILLA_WAFER)
DEFINE_ACTION_MULTI ("send-wafer", ACTION_MULTI_WAFER)
+DEFINE_ACTION_MULTI ("server-header-filter", ACTION_MULTI_SERVER_HEADER_FILTER)
DEFINE_ACTION_BOOL ("session-cookies-only", ACTION_NO_COOKIE_KEEP)
DEFINE_ACTION_STRING ("set-image-blocker", ACTION_IMAGE_BLOCKER, ACTION_STRING_IMAGE_BLOCKER)
DEFINE_CGI_PARAM_RADIO ("set-image-blocker", ACTION_IMAGE_BLOCKER, ACTION_STRING_IMAGE_BLOCKER, "pattern", 1)
DEFINE_ACTION_STRING ("hide-referer", ACTION_HIDE_REFERER, ACTION_STRING_REFERER)
DEFINE_ACTION_BOOL ("prevent-keeping-cookies", ACTION_NO_COOKIE_KEEP)
+/*
+ * Pre-3.0.7 (pseudo) compatibility
+ */
+DEFINE_ACTION_MULTI ("filter-client-headers", ACTION_MULTI_CLIENT_HEADER_FILTER)
+DEFINE_ACTION_MULTI ("filter-server-headers", ACTION_MULTI_SERVER_HEADER_FILTER)
+
/*
* Pre-3.0 compatibility
*/
-const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.47 2006/12/28 18:04:25 fabiankeil Exp $";
+const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.48 2007/02/13 14:35:25 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/cgiedit.c,v $
*
* Revisions :
* $Log: cgiedit.c,v $
+ * Revision 1.48 2007/02/13 14:35:25 fabiankeil
+ * Replace hash escaping code to prevent
+ * crashes, memory and file corruption.
+ *
* Revision 1.47 2006/12/28 18:04:25 fabiankeil
* Fixed gcc43 conversion warnings.
*
}
if (0 == have_filters)
+ {
err = map(exports, "filter-params", 1, "", 1);
+ }
else
{
- /* We have some entries in the filter list */
+ /*
+ * List available filters and their settings.
+ *
+ * XXX: Different types of filters should use different
+ * @substitution strings@. They are currently listed
+ * in the order they appear in the filter files and
+ * are all inserted as @filter-params@ which can lead
+ * to an "interesting" mix.
+ */
char * result;
int filter_identifier = 0;
char * filter_template;
char * this_line;
struct map *line_exports;
char number[20];
+ int multi_action_index = 0;
+ char *filter_type;
+ char *abbr_filter_type;
- filter_name = cur_line->data.action->multi_add[ACTION_MULTI_FILTER]->first;
+ switch (filter_group->type)
+ {
+ case FT_CONTENT_FILTER:
+ /* XXX: Should we call it content-filter instead? */
+ filter_type = "filter";
+ abbr_filter_type = "F";
+ multi_action_index = ACTION_MULTI_FILTER;
+ break;
+ case FT_SERVER_HEADER_FILTER:
+ filter_type = "server-header-filter";
+ abbr_filter_type = "S";
+ multi_action_index = ACTION_MULTI_SERVER_HEADER_FILTER;
+ break;
+ case FT_CLIENT_HEADER_FILTER:
+ filter_type = "client-header-filter";
+ abbr_filter_type = "C";
+ multi_action_index = ACTION_MULTI_CLIENT_HEADER_FILTER;
+ break;
+ default:
+ log_error(LOG_LEVEL_FATAL,
+ "cgi_edit_actions_for_url: Unknown filter type: %u for filter %s.",
+ filter_group->type, filter_group->name);
+ /* Not reached. */
+ }
+ assert(multi_action_index);
+
+ filter_name = cur_line->data.action->multi_add[multi_action_index]->first;
while ((filter_name != NULL)
&& (0 != strcmp(filter_group->name, filter_name->str)))
{
}
else
{
- filter_name = cur_line->data.action->multi_remove[ACTION_MULTI_FILTER]->first;
+ filter_name = cur_line->data.action->multi_remove[multi_action_index]->first;
while ((filter_name != NULL)
&& (0 != strcmp(filter_group->name, filter_name->str)))
{
if (!err) err = map(line_exports, "name", 1, filter_group->name, 1);
if (!err) err = map(line_exports, "description", 1, filter_group->description, 1);
if (!err) err = map_radio(line_exports, "this-filter", "ynx", current_mode);
+ if (!err) err = map(line_exports, "filter-type", 1, filter_type, 1);
+ if (!err) err = map(line_exports, "abbr-filter-type", 1, abbr_filter_type, 1);
this_line = NULL;
if (!err)
{
char key_value[30];
char key_name[30];
+ char key_type[30];
const char *name;
- char value;
+ char value; /*
+ * Filter state. Valid states are: 'Y' (active),
+ * 'N' (inactive) and 'X' (no change).
+ * XXX: bad name.
+ */
+ char type; /*
+ * Abbreviated filter type. Valid types are: 'F' (content filter),
+ * 'S' (server-header filter) and 'C' (client-header filter).
+ */
+ int multi_action_index = 0;
/* Generate the keys */
snprintf(key_value, sizeof(key_value), "filter_r%x", filter_identifier);
- key_value[sizeof(key_value) - 1] = '\0';
+ key_value[sizeof(key_value) - 1] = '\0'; /* XXX: Why? */
snprintf(key_name, sizeof(key_name), "filter_n%x", filter_identifier);
- key_name[sizeof(key_name) - 1] = '\0';
+ key_name[sizeof(key_name) - 1] = '\0'; /* XXX: Why? */
+ snprintf(key_type, sizeof(key_type), "filter_t%x", filter_identifier);
err = get_string_param(parameters, key_name, &name);
if (err) break;
break;
}
+ type = get_char_param(parameters, key_type);
+ switch (type)
+ {
+ case 'F':
+ multi_action_index = ACTION_MULTI_FILTER;
+ break;
+ case 'S':
+ multi_action_index = ACTION_MULTI_SERVER_HEADER_FILTER;
+ break;
+ case 'C':
+ multi_action_index = ACTION_MULTI_CLIENT_HEADER_FILTER;
+ break;
+ default:
+ log_error(LOG_LEVEL_ERROR,
+ "Unknown filter type: %c for filter %s. Filter ignored.", type, name);
+ continue;
+ }
+ assert(multi_action_index);
+
value = get_char_param(parameters, key_value);
if (value == 'Y')
{
- list_remove_item(cur_line->data.action->multi_add[ACTION_MULTI_FILTER], name);
- if (!err) err = enlist(cur_line->data.action->multi_add[ACTION_MULTI_FILTER], name);
- list_remove_item(cur_line->data.action->multi_remove[ACTION_MULTI_FILTER], name);
+ list_remove_item(cur_line->data.action->multi_add[multi_action_index], name);
+ if (!err) err = enlist(cur_line->data.action->multi_add[multi_action_index], name);
+ list_remove_item(cur_line->data.action->multi_remove[multi_action_index], name);
}
else if (value == 'N')
{
- list_remove_item(cur_line->data.action->multi_add[ACTION_MULTI_FILTER], name);
- if (!cur_line->data.action->multi_remove_all[ACTION_MULTI_FILTER])
+ list_remove_item(cur_line->data.action->multi_add[multi_action_index], name);
+ if (!cur_line->data.action->multi_remove_all[multi_action_index])
{
- list_remove_item(cur_line->data.action->multi_remove[ACTION_MULTI_FILTER], name);
- if (!err) err = enlist(cur_line->data.action->multi_remove[ACTION_MULTI_FILTER], name);
+ list_remove_item(cur_line->data.action->multi_remove[multi_action_index], name);
+ if (!err) err = enlist(cur_line->data.action->multi_remove[multi_action_index], name);
}
}
else if (value == 'X')
{
- list_remove_item(cur_line->data.action->multi_add[ACTION_MULTI_FILTER], name);
- list_remove_item(cur_line->data.action->multi_remove[ACTION_MULTI_FILTER], name);
+ list_remove_item(cur_line->data.action->multi_add[multi_action_index], name);
+ list_remove_item(cur_line->data.action->multi_remove[multi_action_index], name);
}
}
-const char filters_rcs[] = "$Id: filters.c,v 1.82 2007/03/13 11:28:43 fabiankeil Exp $";
+const char filters_rcs[] = "$Id: filters.c,v 1.83 2007/03/17 15:20:05 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/filters.c,v $
*
* Revisions :
* $Log: filters.c,v $
+ * Revision 1.83 2007/03/17 15:20:05 fabiankeil
+ * New config option: enforce-blocks.
+ *
* Revision 1.82 2007/03/13 11:28:43 fabiankeil
* - Fix port handling in acl_addr() and use a temporary acl spec
* copy so error messages don't contain a truncated version.
*/
for (b = fl->f; b; b = b->next)
{
+ if (b->type != FT_CONTENT_FILTER)
+ {
+ /* Skip header filters */
+ continue;
+ }
+
for (filtername = csp->action->multi[ACTION_MULTI_FILTER]->first;
filtername ; filtername = filtername->next)
{
-const char loaders_rcs[] = "$Id: loaders.c,v 1.58 2006/12/31 14:25:20 fabiankeil Exp $";
+const char loaders_rcs[] = "$Id: loaders.c,v 1.59 2007/01/25 13:38:20 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/loaders.c,v $
*
* Revisions :
* $Log: loaders.c,v $
+ * Revision 1.59 2007/01/25 13:38:20 fabiankeil
+ * Freez csp->error_message in sweep().
+ *
* Revision 1.58 2006/12/31 14:25:20 fabiankeil
* Fix gcc43 compiler warnings.
*
*/
while (read_config_line(buf, sizeof(buf), fp, &linenum) != NULL)
{
+ int new_filter = 0;
+
+ if (strncmp(buf, "FILTER:", 7) == 0)
+ {
+ new_filter = FT_CONTENT_FILTER;
+ }
+ else if (strncmp(buf, "SERVER-HEADER-FILTER:", 21) == 0)
+ {
+ new_filter = FT_SERVER_HEADER_FILTER;
+ }
+ else if (strncmp(buf, "CLIENT-HEADER-FILTER:", 21) == 0)
+ {
+ new_filter = FT_CLIENT_HEADER_FILTER;
+ }
+
/*
* If this is the head of a new filter block, make it a
* re_filterfile spec of its own and chain it to the list:
*/
- if (strncmp(buf, "FILTER:", 7) == 0)
+ if (new_filter != 0)
{
new_bl = (struct re_filterfile_spec *)zalloc(sizeof(*bl));
if (new_bl == NULL)
{
goto load_re_filterfile_error;
}
-
- new_bl->name = chomp(buf + 7);
+ if (new_filter == FT_CONTENT_FILTER)
+ {
+ new_bl->name = chomp(buf + 7);
+ }
+ else
+ {
+ new_bl->name = chomp(buf + 21);
+ }
+ new_bl->type = new_filter;
/*
* If a filter description is available,
#ifndef PROJECT_H_INCLUDED
#define PROJECT_H_INCLUDED
/** Version string. */
-#define PROJECT_H_VERSION "$Id: project.h,v 1.91 2007/03/05 13:28:03 fabiankeil Exp $"
+#define PROJECT_H_VERSION "$Id: project.h,v 1.92 2007/03/17 15:20:05 fabiankeil Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/project.h,v $
*
* Revisions :
* $Log: project.h,v $
+ * Revision 1.92 2007/03/17 15:20:05 fabiankeil
+ * New config option: enforce-blocks.
+ *
* Revision 1.91 2007/03/05 13:28:03 fabiankeil
* Add some CSP_FLAGs for the header parsers.
*
#define ACTION_STRING_COUNT 15
-/*To make the ugly hack in sed easier to understand*/
+/* To make the ugly hack in sed easier to understand */
#define CHECK_EVERY_HEADER_REMAINING 0
/** Index into current_action_spec::multi[] for headers to add. */
-#define ACTION_MULTI_ADD_HEADER 0
+#define ACTION_MULTI_ADD_HEADER 0
/** Index into current_action_spec::multi[] for headers to add. */
-#define ACTION_MULTI_WAFER 1
-/** Index into current_action_spec::multi[] for filters to apply. */
-#define ACTION_MULTI_FILTER 2
+#define ACTION_MULTI_WAFER 1
+/** Index into current_action_spec::multi[] for content filters to apply. */
+#define ACTION_MULTI_FILTER 2
+/** Index into current_action_spec::multi[] for server-header filters to apply. */
+#define ACTION_MULTI_SERVER_HEADER_FILTER 3
+/** Index into current_action_spec::multi[] for client-header filters to apply. */
+#define ACTION_MULTI_CLIENT_HEADER_FILTER 4
/** Number of multi-string actions. */
-#define ACTION_MULTI_COUNT 3
+#define ACTION_MULTI_COUNT 5
/**
*/
#define FORWARD_SPEC_INITIALIZER { { URL_SPEC_INITIALIZER }, 0, NULL, 0, NULL, 0, NULL }
+/* Supported filter types */
+#define FT_CONTENT_FILTER 1
+#define FT_CLIENT_HEADER_FILTER 2
+#define FT_SERVER_HEADER_FILTER 3
/**
* This struct represents one filter (one block) from
char *description; /**< Description from FILTER: statement in re_filterfile. */
struct list patterns[1]; /**< The patterns from the re_filterfile. */
pcrs_job *joblist; /**< The resulting compiled pcrs_jobs. */
+ int type; /**< Filter type (content, client-header, server-header). */
struct re_filterfile_spec *next; /**< The pointer for chaining. */
};