You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by co...@apache.org on 2023/03/19 21:33:35 UTC

svn commit: r1908538 - in /httpd/httpd/branches/2.4.x: ./ changes-entries/mod_mime_nocanon.txt modules/http/mod_mime.c modules/proxy/proxy_util.c

Author: covener
Date: Sun Mar 19 21:33:35 2023
New Revision: 1908538

URL: http://svn.apache.org/viewvc?rev=1908538&view=rev
Log:
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

Added:
    httpd/httpd/branches/2.4.x/changes-entries/mod_mime_nocanon.txt
      - copied unchanged from r1908186, httpd/httpd/trunk/changes-entries/mod_mime_nocanon.txt
Modified:
    httpd/httpd/branches/2.4.x/   (props changed)
    httpd/httpd/branches/2.4.x/modules/http/mod_mime.c
    httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.c

Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
  Merged /httpd/httpd/trunk:r1907505,1907565,1908186

Modified: httpd/httpd/branches/2.4.x/modules/http/mod_mime.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/http/mod_mime.c?rev=1908538&r1=1908537&r2=1908538&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/http/mod_mime.c (original)
+++ httpd/httpd/branches/2.4.x/modules/http/mod_mime.c Sun Mar 19 21:33:35 2023
@@ -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;
     }

Modified: httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.c?rev=1908538&r1=1908537&r2=1908538&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.c (original)
+++ httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.c Sun Mar 19 21:33:35 2023
@@ -261,12 +261,13 @@ PROXY_DECLARE(char *)ap_proxy_canonenc(a
                 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)) {



Re: svn commit: r1908538 - in /httpd/httpd/branches/2.4.x: ./ changes-entries/mod_mime_nocanon.txt modules/http/mod_mime.c modules/proxy/proxy_util.c

Posted by Eric Covener <co...@gmail.com>.
last bit in proxy_util is approved as well but committed inadvertently.

On Sun, Mar 19, 2023 at 5:33 PM <co...@apache.org> wrote:
>
> Author: covener
> Date: Sun Mar 19 21:33:35 2023
> New Revision: 1908538
>
> URL: http://svn.apache.org/viewvc?rev=1908538&view=rev
> Log:
> 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
>
> Added:
>     httpd/httpd/branches/2.4.x/changes-entries/mod_mime_nocanon.txt
>       - copied unchanged from r1908186, httpd/httpd/trunk/changes-entries/mod_mime_nocanon.txt
> Modified:
>     httpd/httpd/branches/2.4.x/   (props changed)
>     httpd/httpd/branches/2.4.x/modules/http/mod_mime.c
>     httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.c
>
> Propchange: httpd/httpd/branches/2.4.x/
> ------------------------------------------------------------------------------
>   Merged /httpd/httpd/trunk:r1907505,1907565,1908186
>
> Modified: httpd/httpd/branches/2.4.x/modules/http/mod_mime.c
> URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/http/mod_mime.c?rev=1908538&r1=1908537&r2=1908538&view=diff
> ==============================================================================
> --- httpd/httpd/branches/2.4.x/modules/http/mod_mime.c (original)
> +++ httpd/httpd/branches/2.4.x/modules/http/mod_mime.c Sun Mar 19 21:33:35 2023
> @@ -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;
>      }
>
> Modified: httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.c
> URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.c?rev=1908538&r1=1908537&r2=1908538&view=diff
> ==============================================================================
> --- httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.c (original)
> +++ httpd/httpd/branches/2.4.x/modules/proxy/proxy_util.c Sun Mar 19 21:33:35 2023
> @@ -261,12 +261,13 @@ PROXY_DECLARE(char *)ap_proxy_canonenc(a
>                  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)) {
>
>


-- 
Eric Covener
covener@gmail.com