]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r1919860 from trunk:
authorEric Covener <covener@apache.org>
Fri, 27 Sep 2024 13:09:43 +0000 (13:09 +0000)
committerEric Covener <covener@apache.org>
Fri, 27 Sep 2024 13:09:43 +0000 (13:09 +0000)
don't merge slashes on perdir prefix

Submitted by: covener
Reviewed by: covener, rpluem, jorton

Github: closes #473

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1920980 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/mappers/mod_rewrite.c

diff --git a/CHANGES b/CHANGES
index cf7ebfc03abded32afa0f9fb10f1500f99ab3702..ffd8cfba1cb7b73c62be2917220f6f5d6d0076f9 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,10 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.4.63
 
+  *) mod_rewrite: Don't require [UNC] flag to preserve a leading //
+     added by applying the perdir prefix to the substitution.
+     [Ruediger Pluem, Eric Covener]
+
   *) Windows: Restore the ability to "Include" configuration files on UNC
      paths. PR69313 [Eric Covener]
 
index 24e21c6f4dcf378ff1b9b395011ab8f78238971e..ef3e52fb79431f1d526a15d40b1cf88a4ecdfb13 100644 (file)
@@ -4322,6 +4322,7 @@ static rule_return_type apply_rewrite_rule(rewriterule_entry *p,
     char *newuri = NULL;
     request_rec *r = ctx->r;
     int is_proxyreq = 0;
+    int prefix_added = 0;
 
     ctx->uri = r->filename;
 
@@ -4483,6 +4484,7 @@ static rule_return_type apply_rewrite_rule(rewriterule_entry *p,
                        newuri, ctx->perdir, newuri);
 
             newuri = apr_pstrcat(r->pool, ctx->perdir, newuri, NULL);
+            prefix_added = 1;
         }
         else if (!(p->flags & (RULEFLAG_PROXY | RULEFLAG_FORCEREDIRECT))) {
             /* Not an absolute URI-path and the scheme (if any) is unknown,
@@ -4496,6 +4498,7 @@ static rule_return_type apply_rewrite_rule(rewriterule_entry *p,
                        newuri, newuri);
 
             newuri = apr_pstrcat(r->pool, "/", newuri, NULL);
+            prefix_added = 1;
         }
     }
 
@@ -4576,7 +4579,7 @@ static rule_return_type apply_rewrite_rule(rewriterule_entry *p,
         return RULE_RC_MATCH;
     }
 
-    if (!(p->flags & RULEFLAG_UNC)) {
+    if (!((p->flags & RULEFLAG_UNC) || prefix_added)) {
         /* merge leading slashes, unless they were literals in the sub */
         if (!AP_IS_SLASH(p->output[0]) || !AP_IS_SLASH(p->output[1])) {
             while (AP_IS_SLASH(r->filename[0]) &&