Skip to content

Commit

Permalink
don't merge slashes on perdir prefix
Browse files Browse the repository at this point in the history
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
(cherry picked from commit c4f3526)
  • Loading branch information
covener authored and Eric Covener committed Aug 13, 2024
1 parent 20c4d07 commit 6d417a1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changes-entries/rewrite-perdir-unc.txt
Original file line number Diff line number Diff line change
@@ -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]
5 changes: 4 additions & 1 deletion modules/mappers/mod_rewrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -4284,6 +4284,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;

Expand Down Expand Up @@ -4444,6 +4445,7 @@ static rule_return_type apply_rewrite_rule(rewriterule_entry *p,
rewritelog((r, 3, ctx->perdir, "add per-dir prefix: %s -> %s%s",
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,
Expand All @@ -4457,6 +4459,7 @@ static rule_return_type apply_rewrite_rule(rewriterule_entry *p,
newuri, newuri));

newuri = apr_pstrcat(r->pool, "/", newuri, NULL);
prefix_added = 1;
}
}

Expand Down Expand Up @@ -4537,7 +4540,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]) &&
Expand Down

0 comments on commit 6d417a1

Please sign in to comment.