]> granicus.if.org Git - apache/commitdiff
Merge r1792589 from trunk:
authorJim Jagielski <jim@apache.org>
Tue, 23 May 2017 12:48:27 +0000 (12:48 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 23 May 2017 12:48:27 +0000 (12:48 +0000)
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

Submitted by: elukey
Reviewed by: elukey, jim, yalvic

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1795906 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
server/request.c

diff --git a/CHANGES b/CHANGES
index 7d600fce3526bfec713def73a24978540ecc573a..ee79766529e440e80a4ba8a433a66a14b3e19874 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@
 
 Changes with Apache 2.4.26
 
+  *) Evaluate nested If/ElseIf/Else configuration blocks.
+     [Luca Toscano, Jacob Champion]
+
   *) mod_substitute: Fix spurious AH01328 (Line too long) errors on EBCDIC
      systems.  [Eric Covener]
 
diff --git a/STATUS b/STATUS
index 855b049c4b3aec7afde0637ec941132ec69e082c..19f15b933c4b7c9fce99d8a93dabcaff90e40274 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -120,12 +120,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-  *) core: evaluate nested If/ElseIf/Else sections rather than silently ignore
-     them.
-     trunk patch: http://svn.apache.org/r1792589
-     2.4.x patch: trunk works (modulo CHANGES)
-     +1: elukey, jim, yalvic
-
    *) confirm ab + https w/ openssl 1.1.0 on unix is OK.
       Gregg says it's broken on Windows.
       Document it somewhere either way.
index 9377836e0f5864ef00827086b8fa12a207c65786..b2280cb5a8ee04b38fa49ce5c5427d9447ac2b28 100644 (file)
@@ -1777,10 +1777,9 @@ AP_DECLARE(int) ap_file_walk(request_rec *r)
     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;
@@ -1791,7 +1790,7 @@ AP_DECLARE(int) ap_if_walk(request_rec *r)
     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;
     }
@@ -1906,9 +1905,25 @@ AP_DECLARE(int) ap_if_walk(request_rec *r)
     }
     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.