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_rewrite.c
Date Wed, 30 Jul 2003 13:37:37 GMT
nd          2003/07/30 06:37:37

  Modified:    modules/mappers mod_rewrite.c
  Log:
  Rewritemap improvement:
  - map designations are now case insensitive (txt: rNd: PRG: INt:)
  - maps may be relative to serverroot, which appears to be _very_
    helpful
  
  Revision  Changes    Path
  1.205     +46 -17    httpd-2.0/modules/mappers/mod_rewrite.c
  
  Index: mod_rewrite.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_rewrite.c,v
  retrieving revision 1.204
  retrieving revision 1.205
  diff -u -r1.204 -r1.205
  --- mod_rewrite.c	30 Jul 2003 00:13:01 -0000	1.204
  +++ mod_rewrite.c	30 Jul 2003 13:37:36 -0000	1.205
  @@ -2613,23 +2613,34 @@
       rewrite_server_conf *sconf;
       rewritemap_entry *newmap;
       apr_finfo_t st;
  +    const char *fname;
   
       sconf = ap_get_module_config(cmd->server->module_config, &rewrite_module);
   
       newmap = apr_palloc(cmd->pool, sizeof(rewritemap_entry));
  -
       newmap->func = NULL;
  -    if (strncmp(a2, "txt:", 4) == 0) {
  +
  +    if (strncasecmp(a2, "txt:", 4) == 0) {
  +        if ((fname = ap_server_root_relative(cmd->pool, a2+4)) == NULL) {
  +            return apr_pstrcat(cmd->pool, "RewriteMap: bad path to txt map: ",
  +                               a2+4, NULL);
  +        }
  +
           newmap->type      = MAPTYPE_TXT;
  -        newmap->datafile  = a2+4;
  -        newmap->checkfile = a2+4;
  +        newmap->datafile  = fname;
  +        newmap->checkfile = fname;
       }
  -    else if (strncmp(a2, "rnd:", 4) == 0) {
  +    else if (strncasecmp(a2, "rnd:", 4) == 0) {
  +        if ((fname = ap_server_root_relative(cmd->pool, a2+4)) == NULL) {
  +            return apr_pstrcat(cmd->pool, "RewriteMap: bad path to rnd map: ",
  +                               a2+4, NULL);
  +        }
  +
           newmap->type      = MAPTYPE_RND;
  -        newmap->datafile  = a2+4;
  -        newmap->checkfile = a2+4;
  +        newmap->datafile  = fname;
  +        newmap->checkfile = fname;
       }
  -    else if (strncmp(a2, "dbm", 3) == 0) {
  +    else if (strncasecmp(a2, "dbm", 3) == 0) {
           const char *ignored_fname;
           int bad = 0;
           apr_status_t rv;
  @@ -2637,8 +2648,8 @@
           newmap->type = MAPTYPE_DBM;
   
           if (a2[3] == ':') {
  -            newmap->dbmtype    = "default";
  -            newmap->datafile   = a2+4;
  +            newmap->dbmtype = "default";
  +            fname = a2+4;
           }
           else if (a2[3] == '=') {
               const char *colon = ap_strchr_c(a2 + 4, ':');
  @@ -2646,7 +2657,7 @@
               if (colon) {
                   newmap->dbmtype = apr_pstrndup(cmd->pool, a2 + 4,
                                                  colon - (a2 + 3) - 1);
  -                newmap->datafile = colon + 1;
  +                fname = colon + 1;
               }
               else {
                   ++bad;
  @@ -2661,6 +2672,12 @@
                                  a2, NULL);
           }
   
  +        if ((newmap->datafile = ap_server_root_relative(cmd->pool,
  +                                                        fname)) == NULL) {
  +            return apr_pstrcat(cmd->pool, "RewriteMap: bad path to dbm map: ",
  +                               fname, NULL);
  +        }
  +
           rv = apr_dbm_get_usednames_ex(cmd->pool, newmap->dbmtype,
                                         newmap->datafile, &newmap->checkfile,
                                         &ignored_fname);
  @@ -2669,14 +2686,21 @@
                                  newmap->dbmtype, " is invalid", NULL);
           }
       }
  -    else if (strncmp(a2, "prg:", 4) == 0) {
  -        newmap->type      = MAPTYPE_PRG;
  +    else if (strncasecmp(a2, "prg:", 4) == 0) {
           apr_tokenize_to_argv(a2 + 4, &newmap->argv, cmd->pool);
  +
  +        fname = newmap->argv[0];
  +        if ((newmap->argv[0] = ap_server_root_relative(cmd->pool,
  +                                                       fname)) == NULL) {
  +            return apr_pstrcat(cmd->pool, "RewriteMap: bad path to prg map: ",
  +                               fname, NULL);
  +        }
  +
  +        newmap->type      = MAPTYPE_PRG;
           newmap->datafile  = NULL;
           newmap->checkfile = newmap->argv[0];
  -
       }
  -    else if (strncmp(a2, "int:", 4) == 0) {
  +    else if (strncasecmp(a2, "int:", 4) == 0) {
           newmap->type      = MAPTYPE_INT;
           newmap->datafile  = NULL;
           newmap->checkfile = NULL;
  @@ -2688,9 +2712,14 @@
           }
       }
       else {
  +        if ((fname = ap_server_root_relative(cmd->pool, a2)) == NULL) {
  +            return apr_pstrcat(cmd->pool, "RewriteMap: bad path to txt map: ",
  +                               a2, NULL);
  +        }
  +
           newmap->type      = MAPTYPE_TXT;
  -        newmap->datafile  = a2;
  -        newmap->checkfile = a2;
  +        newmap->datafile  = fname;
  +        newmap->checkfile = fname;
       }
       newmap->fpin  = NULL;
       newmap->fpout = NULL;
  
  
  

Mime
View raw message