]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Follow up to r1879079, r1879080: change to DONE semantics for pre_trans hooks.
authorYann Ylavic <ylavic@apache.org>
Wed, 24 Jun 2020 07:47:58 +0000 (07:47 +0000)
committerYann Ylavic <ylavic@apache.org>
Wed, 24 Jun 2020 07:47:58 +0000 (07:47 +0000)
Don't decode r->uri when pre_trans returns DONE instead of OK, which allows to
preserve previous behaviour where decoding was avoided for "ProxyRequests on"
or post_read_request RewriteRule [P] only, but not ProxyPass'ed requests.

This also preserves decoded location walk in most/same cases.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1879137 13f79535-47bb-0310-9956-ffa450edef68

include/http_request.h
modules/proxy/mod_proxy.c
server/request.c

index 8f283975eac3c0abdd3eca51c6ca65070befd0b7..93defac28546c219fffce3ece58fc317f71f9103 100644 (file)
@@ -366,7 +366,10 @@ AP_DECLARE_HOOK(int,create_request,(request_rec *r))
  * This hook allow modules an opportunity to translate the URI into an
  * actual filename, before URL decoding happens.
  * @param r The current request
- * @return OK, DECLINED, or HTTP_...
+ * @return DECLINED to let other modules handle the pre-translation,
+ *         OK if it was handled and no other module should process it,
+ *         DONE if no further transformation should happen on the URI,
+ *         HTTP_... in case of error.
  * @ingroup hooks
  */
 AP_DECLARE_HOOK(int,pre_translate_name,(request_rec *r))
index 19628ac0b86635ce271d7d936f38b88620c341be..2d32b6db2cd21463f8c619301a9e65a0b3d671d5 100644 (file)
@@ -1007,9 +1007,10 @@ static int proxy_trans(request_rec *r, int pre_trans)
 
     if (r->proxyreq) {
         /* someone has already set up the proxy, it was possibly ourselves
-         * in proxy_detect
+         * in proxy_detect (DONE will prevent further decoding of r->uri,
+         * only if proxyreq is set before pre_trans already).
          */
-        return OK;
+        return pre_trans ? DONE : OK;
     }
 
     /* In early pre_trans hook, r->uri was not manipulated yet so we are
index 258b853633cdcae9b8f0aefd59d06a97bf34ebb7..4ba347ae40c0d8719da5a21324579d1cfa5e6caa 100644 (file)
@@ -227,11 +227,11 @@ AP_DECLARE(int) ap_process_request_internal(request_rec *r)
             return access_status;
         }
 
-        /* Let pre_translate_name hooks work with non-decoded URIs,
-         * and eventually apply their own transformations (return OK).
+        /* Let pre_translate_name hooks work with non-decoded URIs, and
+         * eventually prevent further URI transformations (return DONE).
          */
         access_status = ap_run_pre_translate_name(r);
-        if (access_status != OK && access_status != DECLINED) {
+        if (ap_is_HTTP_ERROR(access_status)) {
             return access_status;
         }
 
@@ -240,7 +240,7 @@ AP_DECLARE(int) ap_process_request_internal(request_rec *r)
     }
 
     /* Ignore URL unescaping for translated URIs already */
-    if (access_status == DECLINED && r->parsed_uri.path) {
+    if (access_status != DONE && r->parsed_uri.path) {
         core_dir_config *d = ap_get_core_module_config(r->per_dir_config);
 
         if (d->allow_encoded_slashes) {