httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n.@apache.org
Subject cvs commit: httpd-2.0/modules/mappers mod_alias.c
Date Fri, 14 Feb 2003 03:51:01 GMT
nd          2003/02/13 19:51:01

  Modified:    modules/mappers mod_alias.c
  Log:
  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
  
  Revision  Changes    Path
  1.45      +25 -0     httpd-2.0/modules/mappers/mod_alias.c
  
  Index: mod_alias.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_alias.c,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- mod_alias.c	3 Feb 2003 17:53:05 -0000	1.44
  +++ mod_alias.c	14 Feb 2003 03:51:01 -0000	1.45
  @@ -137,6 +137,9 @@
       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 @@
       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. */
   
  @@ -164,6 +169,26 @@
       }
       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;
   }
  
  
  

Mime
View raw message