You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ni...@apache.org on 2007/07/26 15:21:21 UTC

svn commit: r559804 - /httpd/httpd/trunk/modules/filters/mod_filter.c

Author: niq
Date: Thu Jul 26 06:21:20 2007
New Revision: 559804

URL: http://svn.apache.org/viewvc?view=rev&rev=559804
Log:
mod_filter: fix merging of ! and =
PR: 42186 - patch by Issac Goldstand

Modified:
    httpd/httpd/trunk/modules/filters/mod_filter.c

Modified: httpd/httpd/trunk/modules/filters/mod_filter.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/filters/mod_filter.c?view=diff&rev=559804&r1=559803&r2=559804
==============================================================================
--- httpd/httpd/trunk/modules/filters/mod_filter.c (original)
+++ httpd/httpd/trunk/modules/filters/mod_filter.c Thu Jul 26 06:21:20 2007
@@ -688,12 +688,20 @@
         break;
 
     case '!':        /* Empty the chain */
-        cfg->chain = NULL;
+                     /** IG: Add a NULL provider to the beginning so that 
+                      *  we can ensure that we'll empty everything before 
+                      *  this when doing config merges later */
+        p = apr_pcalloc(cmd->pool, sizeof(mod_filter_chain));
+        p->fname = NULL;
+        cfg->chain = p;
         break;
 
     case '=':        /* initialise chain with this arg */
+                     /** IG: Prepend a NULL provider to the beginning as above */
         p = apr_pcalloc(cmd->pool, sizeof(mod_filter_chain));
-        p->fname = arg+1;
+        p->fname = NULL;
+        p->next = apr_pcalloc(cmd->pool, sizeof(mod_filter_chain));
+        p->next->fname = arg+1;
         cfg->chain = p;
         break;
 
@@ -739,6 +747,14 @@
     ap_set_module_config(r->request_config, &filter_module, ctx);
 #endif
 
+    /** IG: Now that we've merged to the final config, go one last time
+     *  through the chain, and prune out the NULL filters */
+
+    for (p = cfg->chain; p; p = p->next) {
+        if (p->fname == NULL) 
+            cfg->chain = p->next;
+    }
+
     for (p = cfg->chain; p; p = p->next) {
         filter = apr_hash_get(cfg->live_filters, p->fname, APR_HASH_KEY_STRING);
         if (filter == NULL) {
@@ -788,7 +804,10 @@
     if (base->chain && add->chain) {
         for (p = base->chain; p; p = p->next) {
             newlink = apr_pmemdup(pool, p, sizeof(mod_filter_chain));
-            if (savelink) {
+            if (newlink->fname == NULL) {
+                conf->chain = savelink = newlink;
+            }
+            else if (savelink) {
                 savelink->next = newlink;
                 savelink = newlink;
             }
@@ -799,8 +818,17 @@
 
         for (p = add->chain; p; p = p->next) {
             newlink = apr_pmemdup(pool, p, sizeof(mod_filter_chain));
-            savelink->next = newlink;
-            savelink = newlink;
+            /** Filter out merged chain resets */
+            if (newlink->fname == NULL) {
+                conf->chain = savelink = newlink;
+            }
+            else if (savelink) {
+                savelink->next = newlink;
+                savelink = newlink;
+            }
+            else {
+                conf->chain = savelink = newlink;
+            }
         }
     }
     else if (add->chain) {