Divide @filter-params@ into @client-header-filter-params@
authorFabian Keil <fk@fabiankeil.de>
Thu, 29 Mar 2007 11:40:34 +0000 (11:40 +0000)
committerFabian Keil <fk@fabiankeil.de>
Thu, 29 Mar 2007 11:40:34 +0000 (11:40 +0000)
@content-filter-params@ and @server-header-filter-params@.

cgiedit.c
templates/edit-actions-for-url
templates/edit-actions-for-url-filter

index 60edc89..fb268c2 100644 (file)
--- a/cgiedit.c
+++ b/cgiedit.c
@@ -1,4 +1,4 @@
-const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.48 2007/02/13 14:35:25 fabiankeil Exp $";
+const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.49 2007/03/20 15:16:34 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgiedit.c,v $
@@ -42,6 +42,11 @@ const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.48 2007/02/13 14:35:25 fabiankeil
  *
  * Revisions   :
  *    $Log: cgiedit.c,v $
+ *    Revision 1.49  2007/03/20 15:16:34  fabiankeil
+ *    Use dedicated header filter actions instead of abusing "filter".
+ *    Replace "filter-client-headers" and "filter-client-headers"
+ *    with "server-header-filter" and "client-header-filter".
+ *
  *    Revision 1.48  2007/02/13 14:35:25  fabiankeil
  *    Replace hash escaping code to prevent
  *    crashes, memory and file corruption.
@@ -3117,16 +3122,12 @@ jb_err cgi_edit_actions_for_url(struct client_state *csp,
    {
       /*
        * 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;
+      char *content_filter_params;
+      char *server_header_filter_params;
+      char *client_header_filter_params;
+      char *filter_template;
       int filter_identifier = 0;
-      char * filter_template;
 
       err = template_load(csp, &filter_template, "edit-actions-for-url-filter", 0);
       if (err)
@@ -3142,7 +3143,9 @@ jb_err cgi_edit_actions_for_url(struct client_state *csp,
 
       err = template_fill(&filter_template, exports);
 
-      result = strdup("");
+      content_filter_params = strdup("");
+      server_header_filter_params = strdup("");
+      client_header_filter_params = strdup("");
 
       for (i = 0; i < MAX_AF_FILES; i++)
       {
@@ -3152,13 +3155,15 @@ jb_err cgi_edit_actions_for_url(struct client_state *csp,
             for (;(!err) && (filter_group != NULL); filter_group = filter_group->next)
             {
                char current_mode = 'x';
-               struct list_entry *filter_name;
-               char * this_line;
-               struct map *line_exports;
                char number[20];
                int multi_action_index = 0;
+               struct list_entry *filter_name;
+               struct map *line_exports;
+               char *this_line;
                char *filter_type;
                char *abbr_filter_type;
+               char *anchor;
+               char **current_params;
 
                switch (filter_group->type)
                {
@@ -3167,16 +3172,22 @@ jb_err cgi_edit_actions_for_url(struct client_state *csp,
                      filter_type = "filter"; 
                      abbr_filter_type = "F";
                      multi_action_index = ACTION_MULTI_FILTER;
+                     anchor = "FILTER";
+                     current_params = &content_filter_params;
                      break;
                   case FT_SERVER_HEADER_FILTER:
                      filter_type = "server-header-filter"; 
                      abbr_filter_type = "S"; 
                      multi_action_index = ACTION_MULTI_SERVER_HEADER_FILTER;
+                     current_params = &server_header_filter_params;
+                     anchor = "SERVER-HEADER-FILTER"; /* XXX: no documentation available yet */
                      break;
                   case FT_CLIENT_HEADER_FILTER:
                      filter_type = "client-header-filter"; 
                      abbr_filter_type = "C"; 
                      multi_action_index = ACTION_MULTI_CLIENT_HEADER_FILTER;
+                     current_params = &client_header_filter_params;
+                     anchor = "CLIENT-HEADER-FILTER"; /* XXX: no documentation available yet */
                      break;
                   default:
                      log_error(LOG_LEVEL_FATAL,
@@ -3219,7 +3230,7 @@ jb_err cgi_edit_actions_for_url(struct client_state *csp,
                if (line_exports == NULL)
                {
                   err = JB_ERR_MEMORY;
-                  freez(result);
+                  freez(*current_params); /* XXX: really necessary? */
                }
                else
                {
@@ -3229,6 +3240,7 @@ jb_err cgi_edit_actions_for_url(struct client_state *csp,
                   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);
+                  if (!err) err = map(line_exports, "anchor", 1, anchor, 1);
 
                   this_line = NULL;
                   if (!err)
@@ -3237,7 +3249,7 @@ jb_err cgi_edit_actions_for_url(struct client_state *csp,
                      if (this_line == NULL) err = JB_ERR_MEMORY;
                   }
                   if (!err) err = template_fill(&this_line, line_exports);
-                  string_join(&result, this_line);
+                  string_join(current_params, this_line);
 
                   free_map(line_exports);
                }
@@ -3246,13 +3258,14 @@ jb_err cgi_edit_actions_for_url(struct client_state *csp,
       }
       freez(filter_template);
 
-      if (!err)
-      {
-         err = map(exports, "filter-params", 1, result, 0);
-      }
-      else
+      if (!err) err = map(exports, "content-filter-params", 1, content_filter_params, 0);
+      if (!err) err = map(exports, "server-header-filter-params", 1, server_header_filter_params, 0);
+      if (!err) err = map(exports, "client-header-filter-params", 1, client_header_filter_params, 0);
+      if (err)
       {
-         freez(result);
+         freez(content_filter_params);
+         freez(server_header_filter_params);
+         freez(client_header_filter_params);
       }
    }
 
index d8cd669..441596f 100644 (file)
@@ -6,7 +6,7 @@
 #                particular section in an actions file.
 # 
 #
-# Copyright   :  Written by and Copyright (C) 2001 the SourceForge
+# Copyright   :  Written by and Copyright (C) 2001-2007 the SourceForge
 #                Privoxy team. http://www.privoxy.org/
 #
 #                Original Author: Copyright (C) 2001 Jonathan Foster
@@ -32,6 +32,9 @@
 #
 # Revisions   :
 #    $Log: edit-actions-for-url,v $
+#    Revision 1.42  2007/03/20 15:40:00  fabiankeil
+#    Adjust to new world order with dedicated header-filter actions.
+#
 #    Revision 1.41  2007/01/23 16:03:16  fabiankeil
 #    - Add favicon links.
 #    - Remove useless W3C validator links.
@@ -510,6 +513,9 @@ function show_send_wafer_opts(tf)
       <td class="action"><a href="@user-manual@@actions-help-prefix@BLOCK">block</a></td>
       <td>Block the request</td>
     </tr>
+
+@client-header-filter-params@
+
    <tr class="bg1" align="left" valign="top">
       <td class="en1" align="center" valign="middle"><input type="radio"
         name="content_type_overwrite" value="Y" @content-type-overwrite-y@
@@ -718,7 +724,9 @@ function show_send_wafer_opts(tf)
         all filters applied by previous rules, and/or you can enable or
         disable the filters individually below.</td>
     </tr>
-@filter-params@
+
+@content-filter-params@
+
 <!-- @if-multiple-forms-start -->
    </table>
    <p>
@@ -1190,6 +1198,9 @@ function show_send_wafer_opts(tf)
         it on if it was off, is not yet supported using this web-based
         editor.</td>
     </tr>
+
+@server-header-filter-params@
+
     <tr class="bg1" align="left" valign="top">
       <td class="en1" align="center" valign="middle"><input type="radio"
         name="session_cookies_only" value="Y" @session-cookies-only-y@
index ea95997..7655965 100644 (file)
@@ -17,6 +17,9 @@
 #
 # Revisions   :
 #    $Log: edit-actions-for-url-filter,v $
+#    Revision 1.7  2007/03/20 15:40:00  fabiankeil
+#    Adjust to new world order with dedicated header-filter actions.
+#
 #
 ##############################################################################
 
@@ -27,7 +30,7 @@
   <td class="action">
     <input type="hidden" name="filter_t@index@" value="@abbr-filter-type@">
     <input type="hidden" name="filter_n@index@" value="@name@">
-    <a href="@user-manual@@actions-help-prefix@FILTER">@filter-type@</a> @name@
+    <a href="@user-manual@@actions-help-prefix@@anchor@">@filter-type@</a> @name@
   </td>
   <td>@description@</td>
 </tr>