summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraham Leggett <minfrin@apache.org>2023-04-14 14:07:49 +0000
committerGraham Leggett <minfrin@apache.org>2023-04-14 14:07:49 +0000
commitc216724c644b0c591df932bc51be6a7d547b25d6 (patch)
treeb0f3150aaa9f449ef6e56bef9b368ca007ffafff
parente6647e0dcbd8372919330b74a037a69d6cf6f0d0 (diff)
downloadhttpd-c216724c644b0c591df932bc51be6a7d547b25d6.tar.gz
mod_alias: When an alias is declared inside a Location, make sure
the balance of the URL is preserved to match the alias declared outside a location. Fixes an error where all requests are mapped to the root of the location. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1909137 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--CHANGES5
-rw-r--r--modules/mappers/mod_alias.c16
2 files changed, 21 insertions, 0 deletions
diff --git a/CHANGES b/CHANGES
index 22f958ab9f..5776d4a06f 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,11 @@
-*- coding: utf-8 -*-
Changes with Apache 2.5.1
+ *) mod_alias: When an alias is declared inside a Location, make sure
+ the balance of the URL is preserved to match the alias declared
+ outside a location. Fixes an error where all requests are mapped
+ to the root of the location. [Graham Leggett]
+
*) core: Be explicit if an enclosing directive contains a path or a
regex. [Graham Leggett]
diff --git a/modules/mappers/mod_alias.c b/modules/mappers/mod_alias.c
index e652d3c100..b1638a34e4 100644
--- a/modules/mappers/mod_alias.c
+++ b/modules/mappers/mod_alias.c
@@ -59,6 +59,7 @@ typedef struct {
unsigned int redirect_set:1;
apr_array_header_t *redirects;
const ap_expr_info_t *alias;
+ const char *alias_fake;
char *handler;
const ap_expr_info_t *redirect;
int redirect_status; /* 301, 302, 303, 410, etc */
@@ -113,6 +114,7 @@ static void *merge_alias_dir_config(apr_pool_t *p, void *basev, void *overridesv
a->redirects = apr_array_append(p, overrides->redirects, base->redirects);
a->alias = (overrides->alias_set == 0) ? base->alias : overrides->alias;
+ a->alias_fake = (overrides->alias_set == 0) ? base->alias_fake : overrides->alias_fake;
a->handler = (overrides->alias_set == 0) ? base->handler : overrides->handler;
a->alias_set = overrides->alias_set || base->alias_set;
@@ -220,6 +222,9 @@ static const char *add_alias(cmd_parms *cmd, void *dummy, const char *fake,
NULL);
}
+ if (!cmd->regex) {
+ dirconf->alias_fake = cmd->path;
+ }
dirconf->handler = cmd->info;
dirconf->alias_set = 1;
@@ -438,6 +443,17 @@ static char *try_alias(request_rec *r)
return PREGSUB_ERROR;
}
+ if (dirconf->alias_fake) {
+ int l;
+
+ l = alias_matches(r->uri, dirconf->alias_fake);
+
+ if (l > 0) {
+ ap_set_context_info(r, dirconf->alias_fake, found);
+ found = apr_pstrcat(r->pool, found, r->uri + l, NULL);
+ }
+ }
+
if (dirconf->handler) { /* Set handler, and leave a note for mod_cgi */
r->handler = dirconf->handler;
apr_table_setn(r->notes, "alias-forced-type", r->handler);