From: André Malo Date: Wed, 30 Jul 2003 13:37:36 +0000 (+0000) Subject: Rewritemap improvement: X-Git-Tag: pre_ajp_proxy~1318 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2ae7b9c92f5e23111f2e0c01f9b82378d4f1aca1;p=apache Rewritemap improvement: - map designations are now case insensitive (txt: rNd: PRG: INt:) - maps may be relative to serverroot, which appears to be _very_ helpful git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@100860 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c index e04408e995..1d8736dd21 100644 --- a/modules/mappers/mod_rewrite.c +++ b/modules/mappers/mod_rewrite.c @@ -2613,23 +2613,34 @@ static const char *cmd_rewritemap(cmd_parms *cmd, void *dconf, const char *a1, 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 @@ static const char *cmd_rewritemap(cmd_parms *cmd, void *dconf, const char *a1, 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 @@ static const char *cmd_rewritemap(cmd_parms *cmd, void *dconf, const char *a1, 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 @@ static const char *cmd_rewritemap(cmd_parms *cmd, void *dconf, const char *a1, 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 @@ static const char *cmd_rewritemap(cmd_parms *cmd, void *dconf, const char *a1, 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 @@ static const char *cmd_rewritemap(cmd_parms *cmd, void *dconf, const char *a1, } } 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;