summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2012-08-06 14:04:06 +0000
committerMaxim Dounin <mdounin@mdounin.ru>2012-08-06 14:04:06 +0000
commit51130c86630cd181f84d41bb702a0748e2260d47 (patch)
treebf867211259c5c6b24592f6e41ac838213d64747 /src
parent94fdcd5e65b079326eb0a2e8c6d3d68a8ea36a1a (diff)
downloadnginx-51130c86630cd181f84d41bb702a0748e2260d47.tar.gz
nginx-51130c86630cd181f84d41bb702a0748e2260d47.tar.bz2
Merge of r4713: map hostnames fix (ticket #182).
The final dot wasn't stripped before looking up in a map of hostnames.
Diffstat (limited to 'src')
-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;