Skip to content

Commit

Permalink
Merge r1919860 from trunk:
Browse files Browse the repository at this point in the history
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
  • Loading branch information
covener committed Sep 27, 2024
1 parent 82736c8 commit be9f2ea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -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]

Expand Down
5 changes: 4 additions & 1 deletion modules/mappers/mod_rewrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand All @@ -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;
}
}

Expand Down Expand Up @@ -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]) &&
Expand Down

0 comments on commit be9f2ea

Please sign in to comment.