From: oes Date: Sat, 16 Mar 2002 20:28:34 +0000 (+0000) Subject: Added descriptions to the filters so users will know what they select in the cgi... X-Git-Tag: v_2_9_12~33 X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=commitdiff_plain;h=d022ae1f6356fe426c054f133d37e3192dc00219 Added descriptions to the filters so users will know what they select in the cgi editor --- diff --git a/cgiedit.c b/cgiedit.c index 6d22a3a1..c6058e7a 100644 --- a/cgiedit.c +++ b/cgiedit.c @@ -1,4 +1,4 @@ -const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.18 2002/03/16 14:57:44 jongfoster Exp $"; +const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.19 2002/03/16 18:38:14 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgiedit.c,v $ @@ -42,6 +42,10 @@ const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.18 2002/03/16 14:57:44 jongfoster * * Revisions : * $Log: cgiedit.c,v $ + * Revision 1.19 2002/03/16 18:38:14 jongfoster + * Stopping stupid or malicious users from breaking the actions + * file using the web-based editor. + * * Revision 1.18 2002/03/16 14:57:44 jongfoster * Full support for enabling/disabling modular filters. * @@ -2935,7 +2939,7 @@ jb_err cgi_edit_actions_for_url(struct client_state *csp, filter_name = cur_line->data.action->multi_add[ACTION_MULTI_FILTER]->first; while ((filter_name != NULL) - && (0 != strcmp(filter_group->filtername, filter_name->str))) + && (0 != strcmp(filter_group->name, filter_name->str))) { filter_name = filter_name->next; } @@ -2948,7 +2952,7 @@ jb_err cgi_edit_actions_for_url(struct client_state *csp, { filter_name = cur_line->data.action->multi_remove[ACTION_MULTI_FILTER]->first; while ((filter_name != NULL) - && (0 != strcmp(filter_group->filtername, filter_name->str))) + && (0 != strcmp(filter_group->name, filter_name->str))) { filter_name = filter_name->next; } @@ -2971,7 +2975,8 @@ jb_err cgi_edit_actions_for_url(struct client_state *csp, else { if (!err) err = map(line_exports, "index", 1, number, 1); - if (!err) err = map(line_exports, "name", 1, filter_group->filtername, 1); + 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); this_line = NULL; diff --git a/loaders.c b/loaders.c index 75f508f6..17cfd157 100644 --- a/loaders.c +++ b/loaders.c @@ -1,4 +1,4 @@ -const char loaders_rcs[] = "$Id: loaders.c,v 1.41 2002/03/12 01:42:50 oes Exp $"; +const char loaders_rcs[] = "$Id: loaders.c,v 1.42 2002/03/13 00:27:05 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/loaders.c,v $ @@ -35,6 +35,9 @@ const char loaders_rcs[] = "$Id: loaders.c,v 1.41 2002/03/12 01:42:50 oes Exp $" * * Revisions : * $Log: loaders.c,v $ + * Revision 1.42 2002/03/13 00:27:05 jongfoster + * Killing warnings + * * Revision 1.41 2002/03/12 01:42:50 oes * Introduced modular filters * @@ -1116,6 +1119,8 @@ static void unload_re_filterfile(void *f) destroy_list(b->patterns); pcrs_free_joblist(b->joblist); + freez(b->name); + freez(b->description); freez(b); b = a; @@ -1144,7 +1149,7 @@ int load_re_filterfile(struct client_state *csp) { FILE *fp; - struct re_filterfile_spec *bl, *new_bl; + struct re_filterfile_spec *new_bl, *bl = NULL; struct file_list *fs; char buf[BUFFER_SIZE]; @@ -1168,21 +1173,6 @@ int load_re_filterfile(struct client_state *csp) goto load_re_filterfile_error; } - /* - * Allocate the first re_filterfile_spec struct - */ - fs->f = bl = (struct re_filterfile_spec *)zalloc(sizeof(*bl)); - if (bl == NULL) - { - goto load_re_filterfile_error; - } - - /* - * Initialize the name in case there are - * expressions before the first block header - */ - bl->filtername = "default"; - /* * Open the file or fail */ @@ -1207,12 +1197,38 @@ int load_re_filterfile(struct client_state *csp) { goto load_re_filterfile_error; } + + new_bl->name = chomp(buf + 7); + + if (NULL != (new_bl->description = strchr(new_bl->name, ' '))) + { + *new_bl->description++ = '\0'; + new_bl->description = strdup(chomp(new_bl->description)); + } + else + { + new_bl->description = strdup("No description available for this filter"); + } + + new_bl->name = strdup(chomp(new_bl->name)); + + /* + * If this is the first filter block, chain it + * to the file_list rather than its (nonexistant) + * predecessor + */ + if (fs->f == NULL) + { + fs->f = new_bl; + } else { - new_bl->filtername = strdup(chomp(buf + 7)); bl->next = new_bl; - bl = new_bl; } + bl = new_bl; + + log_error(LOG_LEVEL_RE_FILTER, "Reading in filter \"%s\" (\"%s\")", bl->name, bl->description); + continue; } @@ -1220,19 +1236,26 @@ int load_re_filterfile(struct client_state *csp) * Else, save the expression, make it a pcrs_job * and chain it into the current filter's joblist */ - enlist(bl->patterns, buf); - - if ((dummy = pcrs_compile_command(buf, &error)) == NULL) + if (bl != NULL) { - log_error(LOG_LEVEL_RE_FILTER, - "Adding re_filter job %s to filter %s failed with error %d.", buf, bl->filtername, error); - continue; + enlist(bl->patterns, buf); + + if ((dummy = pcrs_compile_command(buf, &error)) == NULL) + { + log_error(LOG_LEVEL_RE_FILTER, + "Adding re_filter job %s to filter %s failed with error %d.", buf, bl->name, error); + continue; + } + else + { + dummy->next = bl->joblist; + bl->joblist = dummy; + log_error(LOG_LEVEL_RE_FILTER, "Adding re_filter job %s to filter %s succeeded.", buf, bl->name); + } } else { - dummy->next = bl->joblist; - bl->joblist = dummy; - log_error(LOG_LEVEL_RE_FILTER, "Adding re_filter job %s to filter %s succeeded.", buf, bl->filtername); + log_error(LOG_LEVEL_ERROR, "Ignoring job %s outside filter block in %s, line %d", buf, csp->config->re_filterfile, linenum); } } diff --git a/project.h b/project.h index 859707f0..581d3aee 100644 --- a/project.h +++ b/project.h @@ -1,6 +1,6 @@ #ifndef PROJECT_H_INCLUDED #define PROJECT_H_INCLUDED -#define PROJECT_H_VERSION "$Id: project.h,v 1.55 2002/03/12 01:42:50 oes Exp $" +#define PROJECT_H_VERSION "$Id: project.h,v 1.56 2002/03/13 20:27:30 oes Exp $" /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/project.h,v $ @@ -36,6 +36,9 @@ * * Revisions : * $Log: project.h,v $ + * Revision 1.56 2002/03/13 20:27:30 oes + * Fixing bug with CT_TABOO + * * Revision 1.55 2002/03/12 01:42:50 oes * Introduced modular filters * @@ -932,7 +935,8 @@ struct forward_spec */ struct re_filterfile_spec { - char *filtername; /* Name from FILTER: statement in re_filterfile (or "default") */ + char *name; /* Name from FILTER: statement in re_filterfile */ + 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 */ struct re_filterfile_spec *next; /* The pointer for chaining */ diff --git a/templates/edit-actions-for-url-filter b/templates/edit-actions-for-url-filter index 15aa2146..06020cba 100644 --- a/templates/edit-actions-for-url-filter +++ b/templates/edit-actions-for-url-filter @@ -2,5 +2,5 @@ -   @name@ +   @description@ (@name@)