You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by yl...@apache.org on 2020/06/23 11:58:54 UTC

svn commit: r1879116 - in /httpd/httpd/trunk: docs/log-message-tags/next-number server/request.c

Author: ylavic
Date: Tue Jun 23 11:58:53 2020
New Revision: 1879116

URL: http://svn.apache.org/viewvc?rev=1879116&view=rev
Log:
Follow up to r1879079: merge/walk locations for pre_trans hooks.

So that their configurations work in directory context.

This requires potentially a third walk in ap_process_request_internal(),
though in most cases it should use ap_walk_location() cache.

Modified:
    httpd/httpd/trunk/docs/log-message-tags/next-number
    httpd/httpd/trunk/server/request.c

Modified: httpd/httpd/trunk/docs/log-message-tags/next-number
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/log-message-tags/next-number?rev=1879116&r1=1879115&r2=1879116&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/log-message-tags/next-number (original)
+++ httpd/httpd/trunk/docs/log-message-tags/next-number Tue Jun 23 11:58:53 2020
@@ -1 +1 @@
-10244
+10245

Modified: httpd/httpd/trunk/server/request.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/request.c?rev=1879116&r1=1879115&r2=1879116&view=diff
==============================================================================
--- httpd/httpd/trunk/server/request.c (original)
+++ httpd/httpd/trunk/server/request.c Tue Jun 23 11:58:53 2020
@@ -160,6 +160,27 @@ AP_DECLARE(int) ap_some_authn_required(r
     return rv;
 }
 
+static int walk_location_and_if(request_rec *r)
+{
+    int access_status;
+
+    if ((access_status = ap_location_walk(r))) {
+        return access_status;
+    }
+    if ((access_status = ap_if_walk(r))) {
+        return access_status;
+    }
+
+    /* Don't set per-dir loglevel if LogLevelOverride is set */
+    if (!r->connection->log) {
+        core_dir_config *d = ap_get_core_module_config(r->per_dir_config);
+        if (d->log)
+            r->log = d->log;
+    }
+
+    return OK;
+}
+
 /* This is the master logic for processing requests.  Do NOT duplicate
  * this logic elsewhere, or the security model will be broken by future
  * API changes.  Each phase must be individually optimized to pick up
@@ -167,15 +188,14 @@ AP_DECLARE(int) ap_some_authn_required(r
  */
 AP_DECLARE(int) ap_process_request_internal(request_rec *r)
 {
+    int access_status = DECLINED;
     int file_req = (r->main && r->filename);
-    int access_status;
-    core_dir_config *d;
     core_server_config *sconf =
         ap_get_core_module_config(r->server->module_config);
     unsigned int normalize_flags = 0;
 
-    if (r->main) {
-        /* Lookup subrequests can have a relative path. */
+    if (file_req) {
+        /* File subrequests can have a relative path. */
         normalize_flags = AP_NORMALIZE_ALLOW_RELATIVE;
     }
 
@@ -187,23 +207,39 @@ AP_DECLARE(int) ap_process_request_inter
         if (!ap_normalize_path(r->parsed_uri.path,
                                normalize_flags |
                                AP_NORMALIZE_DECODE_UNRESERVED)) {
-            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO()
-                          "invalid URI path (%s)", r->uri);
+            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(10244)
+                          "invalid URI path (%s)", r->unparsed_uri);
             return HTTP_BAD_REQUEST;
         }
     }
 
-    /* Let pre_translate_name hooks work with non-decoded URIs,
-     * and eventually apply their own transformations (return OK).
+    /* All file subrequests are a huge pain... they cannot bubble through the
+     * next several steps.  Only file subrequests are allowed an empty uri,
+     * otherwise let (pre_)translate_name kill the request.
      */
-    access_status = ap_run_pre_translate_name(r);
-    if (access_status != OK && access_status != DECLINED) {
-        return access_status;
+    if (!file_req) {
+        ap_conf_vector_t *per_dir_config = r->per_dir_config;
+
+        if ((access_status = walk_location_and_if(r))) {
+            return access_status;
+        }
+
+        /* Let pre_translate_name hooks work with non-decoded URIs,
+         * and eventually apply their own transformations (return OK).
+         */
+        access_status = ap_run_pre_translate_name(r);
+        if (access_status != OK && access_status != DECLINED) {
+            return access_status;
+        }
+
+        /* Throw away pre_trans only merging */
+        r->per_dir_config = per_dir_config;
     }
 
     /* Ignore URL unescaping for translated URIs already */
     if (access_status == DECLINED && r->parsed_uri.path) {
-        d = ap_get_core_module_config(r->per_dir_config);
+        core_dir_config *d = ap_get_core_module_config(r->per_dir_config);
+
         if (d->allow_encoded_slashes) {
             access_status = ap_unescape_url_keep2f(r->parsed_uri.path,
                                                    d->decode_encoded_slashes);
@@ -215,9 +251,8 @@ AP_DECLARE(int) ap_process_request_inter
             if (access_status == HTTP_NOT_FOUND) {
                 if (! d->allow_encoded_slashes) {
                     ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, APLOGNO(00026)
-                                  "found %%2f (encoded '/') in URI "
-                                  "(decoded='%s'), returning 404",
-                                  r->uri);
+                                  "found %%2f (encoded '/') in URI path (%s), "
+                                  "returning 404", r->unparsed_uri);
                 }
             }
             return access_status;
@@ -239,25 +274,12 @@ AP_DECLARE(int) ap_process_request_inter
         }
     }
 
-    /* All file subrequests are a huge pain... they cannot bubble through the
-     * next several steps.  Only file subrequests are allowed an empty uri,
-     * otherwise let translate_name kill the request.
-     */
+    /* Same, translate_name is not suited for file subrequests */
     if (!file_req) {
-        if ((access_status = ap_location_walk(r))) {
-            return access_status;
-        }
-        if ((access_status = ap_if_walk(r))) {
+        if ((access_status = walk_location_and_if(r))) {
             return access_status;
         }
 
-        /* Don't set per-dir loglevel if LogLevelOverride is set */
-        if (!r->connection->log) {
-            d = ap_get_core_module_config(r->per_dir_config);
-            if (d->log)
-                r->log = d->log;
-        }
-
         if ((access_status = ap_run_translate_name(r))) {
             return decl_die(access_status, "translate", r);
         }
@@ -274,20 +296,10 @@ AP_DECLARE(int) ap_process_request_inter
 
     /* Rerun the location walk, which overrides any map_to_storage config.
      */
-    if ((access_status = ap_location_walk(r))) {
-        return access_status;
-    }
-    if ((access_status = ap_if_walk(r))) {
+    if ((access_status = walk_location_and_if(r))) {
         return access_status;
     }
 
-    /* Don't set per-dir loglevel if LogLevelOverride is set */
-    if (!r->connection->log) {
-        d = ap_get_core_module_config(r->per_dir_config);
-        if (d->log)
-            r->log = d->log;
-    }
-
     if ((access_status = ap_run_post_perdir_config(r))) {
         return access_status;
     }