aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules/ngx_http_map_module.c
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@nginx.com>2012-06-29 20:33:26 +0000
committerRuslan Ermilov <ru@nginx.com>2012-06-29 20:33:26 +0000
commitf9c03b49eb35db5c0755fc51690c404353bf5b2c (patch)
tree5d7f992736d742cd1533aa5ce924991d096c57a8 /src/http/modules/ngx_http_map_module.c
parent56cb80834c3fdfb4a8c095c14c9e133bc251ec88 (diff)
downloadnginx-f9c03b49eb35db5c0755fc51690c404353bf5b2c.tar.gz
nginx-f9c03b49eb35db5c0755fc51690c404353bf5b2c.zip
map: strip final dot before looking up in a map of hostnames.
(closes #182)
Diffstat (limited to 'src/http/modules/ngx_http_map_module.c')
-rw-r--r--src/http/modules/ngx_http_map_module.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/http/modules/ngx_http_map_module.c b/src/http/modules/ngx_http_map_module.c
index 2fe925f1c..e8a4ab4cc 100644
--- a/src/http/modules/ngx_http_map_module.c
+++ b/src/http/modules/ngx_http_map_module.c
@@ -110,7 +110,6 @@ ngx_http_map_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
{
ngx_http_map_ctx_t *map = (ngx_http_map_ctx_t *) data;
- size_t len;
ngx_str_t val;
ngx_http_variable_value_t *value;
@@ -121,10 +120,8 @@ ngx_http_map_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
return NGX_ERROR;
}
- len = val.len;
-
- if (len && map->hostnames && val.data[len - 1] == '.') {
- len--;
+ if (map->hostnames && val.len > 0 && val.data[val.len - 1] == '.') {
+ val.len--;
}
value = ngx_http_map_find(r, &map->map, &val);
@@ -281,6 +278,8 @@ ngx_http_map_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
map->default_value = ctx.default_value ? ctx.default_value:
&ngx_http_variable_null_value;
+ map->hostnames = ctx.hostnames;
+
hash.key = ngx_hash_key_lc;
hash.max_size = mcf->hash_max_size;
hash.bucket_size = mcf->hash_bucket_size;