You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by el...@apache.org on 2017/04/25 09:06:26 UTC

svn commit: r1792589 - in /httpd/httpd/trunk: CHANGES server/request.c

Author: elukey
Date: Tue Apr 25 09:06:26 2017
New Revision: 1792589

URL: http://svn.apache.org/viewvc?rev=1792589&view=rev
Log:
Evaluate nested If/ElseIf/Else config sections

It has been reported multiple times that nested
If/ElseIf/Else sections are not evaluated but
silently ignored.

This patch adds a simple recursion to the ap_if_walk
logic in order to allow arbitrary nested configs.
The overhead seems negligible compared to the actual
version of the ap_if_walk, but more expert feedback
is surely needed since this code gets called for every
HTTP request.

Tests are going to be added to t/apache/if_sections.t


Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/server/request.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1792589&r1=1792588&r2=1792589&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Tue Apr 25 09:06:26 2017
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) Evaluate nested If/ElseIf/Else configuration blocks.
+     [Luca Toscano, Jacob Champion]
+
   *) Introduce request taint checking framework to prevent privilege
      hijacking through .htaccess. [Nick Kew]
 

Modified: httpd/httpd/trunk/server/request.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/request.c?rev=1792589&r1=1792588&r2=1792589&view=diff
==============================================================================
--- httpd/httpd/trunk/server/request.c (original)
+++ httpd/httpd/trunk/server/request.c Tue Apr 25 09:06:26 2017
@@ -1781,10 +1781,9 @@ AP_DECLARE(int) ap_file_walk(request_rec
     return OK;
 }
 
-AP_DECLARE(int) ap_if_walk(request_rec *r)
+static int ap_if_walk_sub(request_rec *r, core_dir_config* dconf)
 {
     ap_conf_vector_t *now_merged = NULL;
-    core_dir_config *dconf = ap_get_core_module_config(r->per_dir_config);
     ap_conf_vector_t **sec_ent = NULL;
     int num_sec = 0;
     walk_cache_t *cache;
@@ -1795,7 +1794,7 @@ AP_DECLARE(int) ap_if_walk(request_rec *
     int prev_result = -1;
     walk_walked_t *last_walk;
 
-    if (dconf->sec_if) {
+    if (dconf && dconf->sec_if) {
         sec_ent = (ap_conf_vector_t **)dconf->sec_if->elts;
         num_sec = dconf->sec_if->nelts;
     }
@@ -1910,9 +1909,25 @@ AP_DECLARE(int) ap_if_walk(request_rec *
     }
     cache->per_dir_result = r->per_dir_config;
 
+    if (now_merged) {
+        core_dir_config *dconf_merged = ap_get_core_module_config(now_merged);
+
+        /* Allow nested <If>s and their configs to get merged
+         * with the current one.
+         */
+        return ap_if_walk_sub(r, dconf_merged);
+    }
+
     return OK;
 }
 
+AP_DECLARE(int) ap_if_walk(request_rec *r)
+{
+    core_dir_config *dconf = ap_get_core_module_config(r->per_dir_config);
+    int status = ap_if_walk_sub(r, dconf);
+    return status;
+}
+
 /*****************************************************************
  *
  * The sub_request mechanism.