]> git.kaiwu.me - nginx.git/commitdiff
change ngx_http_map_find(): use case sensitive regexes
authorIgor Sysoev <igor@sysoev.ru>
Mon, 30 May 2011 12:36:17 +0000 (12:36 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Mon, 30 May 2011 12:36:17 +0000 (12:36 +0000)
src/http/modules/ngx_http_map_module.c
src/http/ngx_http_variables.c
src/http/ngx_http_variables.h

index 5aa23eba31a2905283b4743f2f98c567422e64cd..8ca3fa314bd260ac456514a7c977aedfd9b911e7 100644 (file)
@@ -111,7 +111,6 @@ ngx_http_map_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
 
     size_t                      len;
     ngx_str_t                   val;
-    ngx_uint_t                  key;
     ngx_http_variable_value_t  *value;
 
     ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
@@ -127,9 +126,7 @@ ngx_http_map_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
         len--;
     }
 
-    key = ngx_hash_strlow(val.data, val.data, len);
-
-    value = ngx_http_map_find(r, &map->map, key, val.data, len, &val);
+    value = ngx_http_map_find(r, &map->map, &val);
 
     if (value == NULL) {
         value = map->default_value;
index 3946e38671042c96edd3e5bf2820cdfaf2a6e788..4afd884059ffaf67000075e6279dd9ee3755cf19 100644 (file)
@@ -1661,14 +1661,30 @@ ngx_http_variable_pid(ngx_http_request_t *r,
 
 
 void *
-ngx_http_map_find(ngx_http_request_t *r, ngx_http_map_t *map, ngx_uint_t key,
-    u_char *text, size_t len, ngx_str_t *match)
+ngx_http_map_find(ngx_http_request_t *r, ngx_http_map_t *map, ngx_str_t *match)
 {
-    void  *p;
+    void        *value;
+    u_char      *low;
+    size_t       len;
+    ngx_uint_t   key;
 
-    p = ngx_hash_find_combined(&map->hash, key, text, len);
-    if (p) {
-        return p;
+    len = match->len;
+
+    if (len) {
+        low = ngx_pnalloc(r->pool, len);
+        if (low == NULL) {
+            return NULL;
+        }
+
+    } else {
+        low = NULL;
+    }
+
+    key = ngx_hash_strlow(low, match->data, len);
+
+    value = ngx_hash_find_combined(&map->hash, key, low, len);
+    if (value) {
+        return value;
     }
 
 #if (NGX_PCRE)
index 8e726364661e3dbd5d1575cd2a95ffe39089936a..b0114e3006d43ac446bfb7af346d14721214661d 100644 (file)
@@ -100,7 +100,7 @@ typedef struct {
 
 
 void *ngx_http_map_find(ngx_http_request_t *r, ngx_http_map_t *map,
-    ngx_uint_t key, u_char *text, size_t len, ngx_str_t *match);
+    ngx_str_t *match);
 
 
 ngx_int_t ngx_http_variables_add_core_vars(ngx_conf_t *cf);