]> git.kaiwu.me - nginx.git/commitdiff
Allow the complex value to be defined as an empty string.
authorRuslan Ermilov <ru@nginx.com>
Thu, 6 Dec 2012 23:03:53 +0000 (23:03 +0000)
committerRuslan Ermilov <ru@nginx.com>
Thu, 6 Dec 2012 23:03:53 +0000 (23:03 +0000)
This makes conversion from strings to complex values possible
without the loss of functionality.

src/http/modules/ngx_http_auth_basic_module.c
src/http/modules/ngx_http_fastcgi_module.c
src/http/modules/ngx_http_proxy_module.c
src/http/modules/ngx_http_scgi_module.c
src/http/modules/ngx_http_sub_filter_module.c
src/http/modules/ngx_http_uwsgi_module.c
src/http/ngx_http_core_module.c
src/http/ngx_http_script.c

index ec3b1cf9500d43d0dad4ccedfafd7890d708c14a..285fb769374aea8694ac74616dcc666b6d411462 100644 (file)
@@ -117,7 +117,7 @@ ngx_http_auth_basic_handler(ngx_http_request_t *r)
 
     alcf = ngx_http_get_module_loc_conf(r, ngx_http_auth_basic_module);
 
-    if (alcf->realm.len == 0 || alcf->user_file.value.len == 0) {
+    if (alcf->realm.len == 0 || alcf->user_file.value.data == NULL) {
         return NGX_DECLINED;
     }
 
@@ -390,7 +390,7 @@ ngx_http_auth_basic_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
         conf->realm = prev->realm;
     }
 
-    if (conf->user_file.value.len == 0) {
+    if (conf->user_file.value.data == NULL) {
         conf->user_file = prev->user_file;
     }
 
@@ -456,7 +456,7 @@ ngx_http_auth_basic_user_file(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
     ngx_str_t                         *value;
     ngx_http_compile_complex_value_t   ccv;
 
-    if (alcf->user_file.value.len) {
+    if (alcf->user_file.value.data) {
         return "is duplicate";
     }
 
index e8ff24cac94c12e17f6c2d50729a1f2758bc88e6..f1917e25de199a0046be9fe1022430d7e8b86a1a 100644 (file)
@@ -3014,7 +3014,7 @@ ngx_http_fastcgi_cache_key(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 
     value = cf->args->elts;
 
-    if (flcf->cache_key.value.len) {
+    if (flcf->cache_key.value.data) {
         return "is duplicate";
     }
 
index b1b8f46daffc9413c5e75610a7c60a9042105634..541c59fd9c1b23f3fc7c1ca6343c238c91b55edd 100644 (file)
@@ -837,7 +837,7 @@ ngx_http_proxy_create_key(ngx_http_request_t *r)
         return NGX_ERROR;
     }
 
-    if (plcf->cache_key.value.len) {
+    if (plcf->cache_key.value.data) {
 
         if (ngx_http_complex_value(r, &plcf->cache_key, key) != NGX_OK) {
             return NGX_ERROR;
@@ -3651,7 +3651,7 @@ ngx_http_proxy_cache_key(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 
     value = cf->args->elts;
 
-    if (plcf->cache_key.value.len) {
+    if (plcf->cache_key.value.data) {
         return "is duplicate";
     }
 
index 2c825fa3a822435f9c6877fb451cc89241749560..5a3af92f96d04a120c5e9a7ee8b7e3ffa3750541 100644 (file)
@@ -1771,7 +1771,7 @@ ngx_http_scgi_cache_key(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 
     value = cf->args->elts;
 
-    if (scf->cache_key.value.len) {
+    if (scf->cache_key.value.data) {
         return "is duplicate";
     }
 
index 989adf5ad9243497d11b2d07100aae6186bb3ed5..6ba57dfffc03dc4a94fd3983b6260622997e0f70 100644 (file)
@@ -628,7 +628,7 @@ ngx_http_sub_filter(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
     ngx_str_t                         *value;
     ngx_http_compile_complex_value_t   ccv;
 
-    if (slcf->match.len) {
+    if (slcf->match.data) {
         return "is duplicate";
     }
 
@@ -688,7 +688,7 @@ ngx_http_sub_merge_conf(ngx_conf_t *cf, void *parent, void *child)
     ngx_conf_merge_value(conf->once, prev->once, 1);
     ngx_conf_merge_str_value(conf->match, prev->match, "");
 
-    if (conf->value.value.len == 0) {
+    if (conf->value.value.data == NULL) {
         conf->value = prev->value;
     }
 
index ef8994c52b042ecd8fa60cc059c85c6e70bf49a6..0c6414c6f82291db9f53e5a94c2d2b6b78420bcd 100644 (file)
@@ -1807,7 +1807,7 @@ ngx_http_uwsgi_cache_key(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 
     value = cf->args->elts;
 
-    if (uwcf->cache_key.value.len) {
+    if (uwcf->cache_key.value.data) {
         return "is duplicate";
     }
 
index faecaddc4aefdc0409ceee7c074e5b0023b8159e..a7db74b988420e908016dd9eaa58ccb81950b075 100644 (file)
@@ -4593,7 +4593,7 @@ ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 
     ngx_str_null(&args);
 
-    if (cv.lengths == NULL && uri.data[0] == '/') {
+    if (cv.lengths == NULL && uri.len && uri.data[0] == '/') {
         p = (u_char *) ngx_strchr(uri.data, '?');
 
         if (p) {
index e214519fca00466920ff6c556ac6a7d71853102f..54d019589a95b4f3e8085ce1fcc36bea44f0d363 100644 (file)
@@ -114,11 +114,6 @@ ngx_http_compile_complex_value(ngx_http_compile_complex_value_t *ccv)
 
     v = ccv->value;
 
-    if (v->len == 0) {
-        ngx_conf_log_error(NGX_LOG_EMERG, ccv->cf, 0, "empty parameter");
-        return NGX_ERROR;
-    }
-
     nv = 0;
     nc = 0;
 
@@ -133,8 +128,9 @@ ngx_http_compile_complex_value(ngx_http_compile_complex_value_t *ccv)
         }
     }
 
-    if (v->data[0] != '$' && (ccv->conf_prefix || ccv->root_prefix)) {
-
+    if ((v->len == 0 || v->data[0] != '$')
+        && (ccv->conf_prefix || ccv->root_prefix))
+    {
         if (ngx_conf_full_name(ccv->cf->cycle, v, ccv->conf_prefix) != NGX_OK) {
             return NGX_ERROR;
         }