diff src/http/modules/ngx_http_ssi_filter_module.c @ 184:71ff1e2b484a NGINX_0_3_39

nginx 0.3.39 *) Feature: the "uninitialized_variable_warn" directive; the logging level of the "uninitialized variable" message was lowered from "alert" to "warn". *) Feature: the "override_charset" directive. *) Change: now if the unknown variable is used in the "echo" and "if expr='$name'" SSI-commands, then the "unknown variable" message is not logged. *) Bugfix: the active connection counter increased on the exceeding of the connection limit specified by the "worker_connections" directive; bug appeared in 0.2.0. *) Bugfix: the limit rate might not work on some condition; bug appeared in 0.3.38.
author Igor Sysoev <http://sysoev.ru>
date Mon, 17 Apr 2006 00:00:00 +0400
parents 87699398f955
children 54aabf2b0bc6
line wrap: on
line diff
--- a/src/http/modules/ngx_http_ssi_filter_module.c
+++ b/src/http/modules/ngx_http_ssi_filter_module.c
@@ -14,6 +14,7 @@
 
 #define NGX_HTTP_SSI_ADD_PREFIX     1
 #define NGX_HTTP_SSI_ADD_ZERO       2
+#define NGX_HTTP_SSI_EXPR_TEST      4
 
 
 typedef struct {
@@ -1502,8 +1503,8 @@ ngx_http_ssi_evaluate_string(ngx_http_re
             val = ngx_http_ssi_get_variable(r, &var, key);
 
             if (val == NULL) {
-                vv = ngx_http_get_variable(r, &var, key);
-
+                vv = ngx_http_get_variable(r, &var, key,
+                                           flags & NGX_HTTP_SSI_EXPR_TEST);
                 if (vv == NULL) {
                     return NGX_ERROR;
                 }
@@ -1681,7 +1682,7 @@ ngx_http_ssi_echo(ngx_http_request_t *r,
     value = ngx_http_ssi_get_variable(r, var, key);
 
     if (value == NULL) {
-        vv = ngx_http_get_variable(r, var, key);
+        vv = ngx_http_get_variable(r, var, key, 1);
 
         if (vv == NULL) {
             return NGX_HTTP_SSI_ERROR;
@@ -1873,10 +1874,12 @@ ngx_http_ssi_if(ngx_http_request_t *r, n
         p++;
     }
 
+    flags = (p == last) ? NGX_HTTP_SSI_EXPR_TEST : 0;
+
     ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                    "left: \"%V\"", &left);
 
-    if (ngx_http_ssi_evaluate_string(r, ctx, &left, 0) != NGX_OK) {
+    if (ngx_http_ssi_evaluate_string(r, ctx, &left, flags) != NGX_OK) {
         return NGX_HTTP_SSI_ERROR;
     }