summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Covener <covener@apache.org>2023-03-19 21:33:35 +0000
committerEric Covener <covener@apache.org>2023-03-19 21:33:35 +0000
commit11d58d4a43939ccd6f0ab3e4bf762c6a9bc8e0a7 (patch)
tree7a9585526ed4b54411bf355a361e714ee2f06b84
parenta356fdbfb93c59a4e359f0a81b38aef31ddd856e (diff)
downloadhttpd-11d58d4a43939ccd6f0ab3e4bf762c6a9bc8e0a7.tar.gz
Merge r1907505, r1908186 from trunk:
* In the reverse proxy case r->filename might contain a query string if the nocanon option was used with ProxyPass. If this is the case cut off the query string as the last parameter in this query string might end up on an extension we take care about, but we only want to match against path components not against query parameters. * Add CHANGES entry for r1907505 [skip ci] Reviewed By: rpluem, ylavic, covener git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1908538 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--changes-entries/mod_mime_nocanon.txt4
-rw-r--r--modules/http/mod_mime.c15
-rw-r--r--modules/proxy/proxy_util.c7
3 files changed, 22 insertions, 4 deletions
diff --git a/changes-entries/mod_mime_nocanon.txt b/changes-entries/mod_mime_nocanon.txt
new file mode 100644
index 0000000000..8ebf1a9b01
--- /dev/null
+++ b/changes-entries/mod_mime_nocanon.txt
@@ -0,0 +1,4 @@
+
+ *) mod_mime: Do not match the extention against possible query string
+ parameters in case ProxyPass was used with the nocanon option.
+ [Ruediger Pluem]
diff --git a/modules/http/mod_mime.c b/modules/http/mod_mime.c
index 03d1c4110b..700f824f32 100644
--- a/modules/http/mod_mime.c
+++ b/modules/http/mod_mime.c
@@ -755,7 +755,7 @@ static int find_ct(request_rec *r)
mime_dir_config *conf;
apr_array_header_t *exception_list;
char *ext;
- const char *fn, *fntmp, *type, *charset = NULL, *resource_name;
+ const char *fn, *fntmp, *type, *charset = NULL, *resource_name, *qm;
int found_metadata = 0;
if (r->finfo.filetype == APR_DIR) {
@@ -775,6 +775,19 @@ static int find_ct(request_rec *r)
if (conf->use_path_info & 1) {
resource_name = apr_pstrcat(r->pool, r->filename, r->path_info, NULL);
}
+ /*
+ * In the reverse proxy case r->filename might contain a query string if
+ * the nocanon option was used with ProxyPass.
+ * If this is the case cut off the query string as the last parameter in
+ * this query string might end up on an extension we take care about, but
+ * we only want to match against path components not against query
+ * parameters.
+ */
+ else if ((r->proxyreq == PROXYREQ_REVERSE)
+ && (apr_table_get(r->notes, "proxy-nocanon"))
+ && ((qm = ap_strchr_c(r->filename, '?')) != NULL)) {
+ resource_name = apr_pstrmemdup(r->pool, r->filename, qm - r->filename);
+ }
else {
resource_name = r->filename;
}
diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c
index 8267f1b932..992dba8fae 100644
--- a/modules/proxy/proxy_util.c
+++ b/modules/proxy/proxy_util.c
@@ -261,12 +261,13 @@ PROXY_DECLARE(char *)ap_proxy_canonenc(apr_pool_t *p, const char *x, int len,
return NULL;
}
ch = ap_proxy_hex2c(&x[i + 1]);
- i += 2;
if (ch != 0 && strchr(reserved, ch)) { /* keep it encoded */
- ap_proxy_c2hex(ch, &y[j]);
- j += 2;
+ y[j++] = x[i++];
+ y[j++] = x[i++];
+ y[j] = x[i];
continue;
}
+ i += 2;
}
/* recode it, if necessary */
if (!apr_isalnum(ch) && !strchr(allowed, ch)) {