From c4f35264e9f30272cd12d9e9d47f0eb041d93b77 Mon Sep 17 00:00:00 2001 From: Eric Covener Date: Tue, 13 Aug 2024 14:12:35 +0000 Subject: [PATCH] don't merge slashes on perdir prefix Submitted by: Eric Covener Github: closes #472 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1919860 13f79535-47bb-0310-9956-ffa450edef68 --- changes-entries/rewrite-perdir-unc.txt | 3 +++ modules/mappers/mod_rewrite.c | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 changes-entries/rewrite-perdir-unc.txt diff --git a/changes-entries/rewrite-perdir-unc.txt b/changes-entries/rewrite-perdir-unc.txt new file mode 100644 index 00000000000..ddc82ee8002 --- /dev/null +++ b/changes-entries/rewrite-perdir-unc.txt @@ -0,0 +1,3 @@ + *) mod_rewrite: Don't require [UNC] flag to preserve a leading // + added by applying the perdir prefix to the substitution. + [Ruediger Pluem, Eric Covener] diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c index e250518f7b3..10ba41a9b5c 100644 --- a/modules/mappers/mod_rewrite.c +++ b/modules/mappers/mod_rewrite.c @@ -4327,6 +4327,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; @@ -4491,6 +4492,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, @@ -4504,6 +4506,7 @@ static rule_return_type apply_rewrite_rule(rewriterule_entry *p, newuri, newuri); newuri = apr_pstrcat(r->pool, "/", newuri, NULL); + prefix_added = 1; } } @@ -4584,7 +4587,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]) &&