From: Yann Ylavic Date: Mon, 22 Jun 2020 10:32:15 +0000 (+0000) Subject: Add pre_translate_name hook running before URI-path decoding. X-Git-Tag: 2.5.0-alpha2-ci-test-only~1360 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2c7a48ff6dadfc582e07c3c46920f44e3bcbb78;p=thirdparty%2Fapache%2Fhttpd.git Add pre_translate_name hook running before URI-path decoding. This allows any module to work with un-decoded URI-path (besides unreserved characters) in r->uri, and eventually to avoid decoding by returning OK. The first candidate is mod_proxy (following commit) when ProxyMappingDecoded is disabled, such that the forwarded URI is equivalent to the original one. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1879076 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 15d2641d1a2..a3ab84498f3 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -633,6 +633,7 @@ * 20200420.2 (2.5.1-dev) Add ap_proxy_worker_can_upgrade() * 20200420.3 (2.5.1-dev) Add ap_parse_strict_length() * 20200420.4 (2.5.1-dev) Add ap_normalize_path() + * 20200420.5 (2.5.1-dev) Add pre_translate_name hook */ #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */ @@ -640,7 +641,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20200420 #endif -#define MODULE_MAGIC_NUMBER_MINOR 4 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 5 /* 0...n */ /** * Determine if the server's current MODULE_MAGIC_NUMBER is at least a diff --git a/include/http_request.h b/include/http_request.h index aedafed89e1..323a0cfcd52 100644 --- a/include/http_request.h +++ b/include/http_request.h @@ -362,6 +362,16 @@ AP_DECLARE(apr_status_t) ap_check_pipeline(conn_rec *c, apr_bucket_brigade *bb, */ 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. + * rules will be followed. + * @param r The current request + * @return OK, DECLINED, or HTTP_... + * @ingroup hooks + */ +AP_DECLARE_HOOK(int,pre_translate_name,(request_rec *r)) + /** * This hook allow modules an opportunity to translate the URI into an * actual filename. If no modules do anything special, the server's default diff --git a/server/request.c b/server/request.c index 1e9a15a28ac..e00ed69d3e5 100644 --- a/server/request.c +++ b/server/request.c @@ -59,6 +59,7 @@ #define APLOG_MODULE_INDEX AP_CORE_MODULE_INDEX APR_HOOK_STRUCT( + APR_HOOK_LINK(pre_translate_name) APR_HOOK_LINK(translate_name) APR_HOOK_LINK(map_to_storage) APR_HOOK_LINK(check_user_id) @@ -74,6 +75,8 @@ APR_HOOK_STRUCT( APR_HOOK_LINK(force_authn) ) +AP_IMPLEMENT_HOOK_RUN_FIRST(int,pre_translate_name, + (request_rec *r), (r), DECLINED) AP_IMPLEMENT_HOOK_RUN_FIRST(int,translate_name, (request_rec *r), (r), DECLINED) AP_IMPLEMENT_HOOK_RUN_FIRST(int,map_to_storage,