From: André Malo Date: Fri, 14 Feb 2003 03:51:01 +0000 (+0000) Subject: people often assume that their Aliases will be found by "best match" rather X-Git-Tag: pre_ajp_proxy~2149 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=34850f47e54459388b4afa0c8fd7c73e625638e9;p=apache people often assume that their Aliases will be found by "best match" rather than "first match". Throw out warnings, if there are obvious overlappings, e.g.: Alias /foo /somewhere Alias /foo/bar /elsewhere git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@98647 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/mappers/mod_alias.c b/modules/mappers/mod_alias.c index 3e21d6f0d6..028f0aa5dd 100644 --- a/modules/mappers/mod_alias.c +++ b/modules/mappers/mod_alias.c @@ -137,6 +137,9 @@ static void *merge_alias_dir_config(apr_pool_t *p, void *basev, void *overridesv return a; } +/* need prototype for overlap check */ +static int alias_matches(const char *uri, const char *alias_fakename); + static const char *add_alias_internal(cmd_parms *cmd, void *dummy, const char *f, const char *r, int use_regex) @@ -145,6 +148,8 @@ static const char *add_alias_internal(cmd_parms *cmd, void *dummy, alias_server_conf *conf = ap_get_module_config(s->module_config, &alias_module); alias_entry *new = apr_array_push(conf->aliases); + alias_entry *entries = (alias_entry *)conf->aliases->elts; + int i; /* XX r can NOT be relative to DocumentRoot here... compat bug. */ @@ -165,6 +170,26 @@ static const char *add_alias_internal(cmd_parms *cmd, void *dummy, new->fake = f; new->handler = cmd->info; + /* check for overlapping (Script)Alias directives + * and throw a warning if found one + */ + if (!use_regex) { + for (i = 0; i < conf->aliases->nelts - 1; ++i) { + alias_entry *p = &entries[i]; + + if (!p->regexp && alias_matches(f, p->fake) > 0) { + ap_log_error(APLOG_MARK, APLOG_WARNING, 0, cmd->server, + "The %s command in line %d will probably never " + "match. Check previous %sAlias commands for " + "overlappings.", cmd->cmd->name, + cmd->directive->line_num, + p->handler ? "Script" : ""); + + break; /* one warning per alias should be sufficient */ + } + } + } + return NULL; }