]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Emit a warning if an alias overlaps another.
authorAndré Malo <nd@apache.org>
Mon, 14 Jun 2004 22:09:42 +0000 (22:09 +0000)
committerAndré Malo <nd@apache.org>
Mon, 14 Jun 2004 22:09:42 +0000 (22:09 +0000)
Reviewed by: Brad Nicholes, Jean-Jacques Clar

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/APACHE_2_0_BRANCH@103950 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
modules/mappers/mod_alias.c

diff --git a/CHANGES b/CHANGES
index b3ad7afc24032061fb9343760fadfd59aefce1b2..ed7cfe95300683a47a6531f5525c32ce747655c7 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,8 @@
 Changes with Apache 2.0.50
 
+  *) mod_alias now emits a warning if it detects overlapping *Alias*
+     directives.  [André Malo]
+
   *) mod_rewrite no longer turns forward proxy requests into reverse proxy
      requests. PR 28125  [ast domdv.de, André Malo]
 
diff --git a/STATUS b/STATUS
index 17e764b18213571a338f6ff877580e24ba02fda4..1e689e7e6c5475e3f9f3b4444cdf99e8bb531918 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -1,5 +1,5 @@
 APACHE 2.0 STATUS:                                              -*-text-*-
-Last modified at [$Date: 2004/06/14 17:48:10 $]
+Last modified at [$Date: 2004/06/14 22:09:41 $]
 
 Release:
 
@@ -180,10 +180,6 @@ PATCHES TO BACKPORT FROM 2.1
           modules/filters/mod_include.c: r1.296
        +1: nd
 
-    *) mod_alias: Emit a warning if an alias overlaps another
-          modules/mappers/mod_alias.c: r1.45, 1.46, 1.47, 1.48, 1.55
-      +1: nd, bnicholes, jjclar
-
     *) Fixed mean and median calculations in ab, also changed where time values
        are set for start and connect when doing keep alive benchmarking.
            support/ab.c: r1.143
index 5279fa86acfdbb8f4d4dadff06ea57653c49b7d5..aaf339c2dda1818494d5158532e7fef4e50d41e1 100644 (file)
@@ -94,6 +94,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)
@@ -102,6 +105,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. */
 
@@ -122,6 +127,29 @@ 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)
+                || (p->regexp && !ap_regexec(p->regexp, f, 0, NULL, 0))) {
+                ap_log_error(APLOG_MARK, APLOG_WARNING, 0, cmd->server,
+                             "The %s directive in %s at line %d will probably "
+                             "never match because it overlaps an earlier "
+                             "%sAlias%s.",
+                             cmd->cmd->name, cmd->directive->filename,
+                             cmd->directive->line_num,
+                             p->handler ? "Script" : "",
+                             p->regexp ? "Match" : "");
+
+                break; /* one warning per alias should be sufficient */
+            }
+        }
+    }
+
     return NULL;
 }