]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r1907505, r1908186 from trunk:
authorEric Covener <covener@apache.org>
Sun, 19 Mar 2023 21:33:35 +0000 (21:33 +0000)
committerEric Covener <covener@apache.org>
Sun, 19 Mar 2023 21:33:35 +0000 (21:33 +0000)
* 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

changes-entries/mod_mime_nocanon.txt [new file with mode: 0644]
modules/http/mod_mime.c
modules/proxy/proxy_util.c

diff --git a/changes-entries/mod_mime_nocanon.txt b/changes-entries/mod_mime_nocanon.txt
new file mode 100644 (file)
index 0000000..8ebf1a9
--- /dev/null
@@ -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]
index 03d1c4110b66d367efdf8ae198ec20474b76f559..700f824f32aac6b63e2b2c27edf9d4154ef75fbd 100644 (file)
@@ -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;
     }
index 8267f1b9326e4858d73ff1bbe1b69b27fb4f22f4..992dba8fae284a467e8a5c69c2e5bf58dfda0048 100644 (file)
@@ -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)) {