Mercurial > hg > nginx-vendor-0-6
comparison src/http/modules/ngx_http_ssi_filter_module.c @ 340:10cc350ed8a1 NGINX_0_6_14
nginx 0.6.14
*) Change: now by default the "echo" SSI command uses entity encoding.
*) Feature: the "encoding" parameter in the "echo" SSI command.
*) Feature: the "access_log" directive may be used inside the
"limit_except" block.
*) Bugfix: if all upstream servers were failed, then all servers had
got weight the was equal one until servers became alive; bug
appeared in 0.6.6.
*) Bugfix: a segmentation fault occurred in worker process if
$date_local and $date_gmt were used outside the
ngx_http_ssi_filter_module.
*) Bugfix: a segmentation fault might occur in worker process if debug
log was enabled.
Thanks to Andrei Nigmatulin.
*) Bugfix: ngx_http_memcached_module did not set
$upstream_response_time.
Thanks to Maxim Dounin.
*) Bugfix: a worker process may got caught in an endless loop, if the
memcached was used.
*) Bugfix: nginx supported low case only "close" and "keep-alive"
values in the "Connection" request header line; bug appeared in
0.6.11.
*) Bugfix: sub_filter did not work with empty substitution.
*) Bugfix: in sub_filter parsing.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 15 Oct 2007 00:00:00 +0400 |
parents | d16d691432c9 |
children | 4276c2f1f434 |
comparison
equal
deleted
inserted
replaced
339:d19550b67059 | 340:10cc350ed8a1 |
---|---|
210 #define NGX_HTTP_SSI_INCLUDE_SET 3 | 210 #define NGX_HTTP_SSI_INCLUDE_SET 3 |
211 #define NGX_HTTP_SSI_INCLUDE_STUB 4 | 211 #define NGX_HTTP_SSI_INCLUDE_STUB 4 |
212 | 212 |
213 #define NGX_HTTP_SSI_ECHO_VAR 0 | 213 #define NGX_HTTP_SSI_ECHO_VAR 0 |
214 #define NGX_HTTP_SSI_ECHO_DEFAULT 1 | 214 #define NGX_HTTP_SSI_ECHO_DEFAULT 1 |
215 #define NGX_HTTP_SSI_ECHO_ENCODING 2 | |
215 | 216 |
216 #define NGX_HTTP_SSI_CONFIG_ERRMSG 0 | 217 #define NGX_HTTP_SSI_CONFIG_ERRMSG 0 |
217 #define NGX_HTTP_SSI_CONFIG_TIMEFMT 1 | 218 #define NGX_HTTP_SSI_CONFIG_TIMEFMT 1 |
218 | 219 |
219 #define NGX_HTTP_SSI_SET_VAR 0 | 220 #define NGX_HTTP_SSI_SET_VAR 0 |
235 | 236 |
236 | 237 |
237 static ngx_http_ssi_param_t ngx_http_ssi_echo_params[] = { | 238 static ngx_http_ssi_param_t ngx_http_ssi_echo_params[] = { |
238 { ngx_string("var"), NGX_HTTP_SSI_ECHO_VAR, 1, 0 }, | 239 { ngx_string("var"), NGX_HTTP_SSI_ECHO_VAR, 1, 0 }, |
239 { ngx_string("default"), NGX_HTTP_SSI_ECHO_DEFAULT, 0, 0 }, | 240 { ngx_string("default"), NGX_HTTP_SSI_ECHO_DEFAULT, 0, 0 }, |
241 { ngx_string("encoding"), NGX_HTTP_SSI_ECHO_ENCODING, 0, 0 }, | |
240 { ngx_null_string, 0, 0, 0 } | 242 { ngx_null_string, 0, 0, 0 } |
241 }; | 243 }; |
242 | 244 |
243 | 245 |
244 static ngx_http_ssi_param_t ngx_http_ssi_config_params[] = { | 246 static ngx_http_ssi_param_t ngx_http_ssi_config_params[] = { |
299 | 301 |
300 | 302 |
301 static ngx_http_variable_t ngx_http_ssi_vars[] = { | 303 static ngx_http_variable_t ngx_http_ssi_vars[] = { |
302 | 304 |
303 { ngx_string("date_local"), NULL, ngx_http_ssi_date_gmt_local_variable, 0, | 305 { ngx_string("date_local"), NULL, ngx_http_ssi_date_gmt_local_variable, 0, |
304 NGX_HTTP_VAR_NOCACHABLE, 0 }, | 306 NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
305 | 307 |
306 { ngx_string("date_gmt"), NULL, ngx_http_ssi_date_gmt_local_variable, 1, | 308 { ngx_string("date_gmt"), NULL, ngx_http_ssi_date_gmt_local_variable, 1, |
307 NGX_HTTP_VAR_NOCACHABLE, 0 }, | 309 NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
308 | 310 |
309 { ngx_null_string, NULL, NULL, 0, 0, 0 } | 311 { ngx_null_string, NULL, NULL, 0, 0, 0 } |
310 }; | 312 }; |
311 | 313 |
312 | 314 |
353 | 355 |
354 | 356 |
355 ctx->value_len = slcf->value_len; | 357 ctx->value_len = slcf->value_len; |
356 ctx->last_out = &ctx->out; | 358 ctx->last_out = &ctx->out; |
357 | 359 |
360 ctx->encoding = NGX_HTTP_SSI_ENTITY_ENCODING; | |
358 ctx->output = 1; | 361 ctx->output = 1; |
359 | 362 |
360 ctx->params.elts = ctx->params_array; | 363 ctx->params.elts = ctx->params_array; |
361 ctx->params.size = sizeof(ngx_table_elt_t); | 364 ctx->params.size = sizeof(ngx_table_elt_t); |
362 ctx->params.nalloc = NGX_HTTP_SSI_PARAMS_N; | 365 ctx->params.nalloc = NGX_HTTP_SSI_PARAMS_N; |
2117 | 2120 |
2118 static ngx_int_t | 2121 static ngx_int_t |
2119 ngx_http_ssi_echo(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, | 2122 ngx_http_ssi_echo(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, |
2120 ngx_str_t **params) | 2123 ngx_str_t **params) |
2121 { | 2124 { |
2125 u_char *p; | |
2126 uintptr_t len; | |
2122 ngx_int_t key; | 2127 ngx_int_t key; |
2123 ngx_uint_t i; | 2128 ngx_uint_t i; |
2124 ngx_buf_t *b; | 2129 ngx_buf_t *b; |
2125 ngx_str_t *var, *value, text; | 2130 ngx_str_t *var, *value, *enc, text; |
2126 ngx_chain_t *cl; | 2131 ngx_chain_t *cl; |
2127 ngx_http_variable_value_t *vv; | 2132 ngx_http_variable_value_t *vv; |
2128 | 2133 |
2129 var = params[NGX_HTTP_SSI_ECHO_VAR]; | 2134 var = params[NGX_HTTP_SSI_ECHO_VAR]; |
2130 | 2135 |
2166 | 2171 |
2167 } else { | 2172 } else { |
2168 if (value->len == 0) { | 2173 if (value->len == 0) { |
2169 return NGX_OK; | 2174 return NGX_OK; |
2170 } | 2175 } |
2176 } | |
2177 | |
2178 enc = params[NGX_HTTP_SSI_ECHO_ENCODING]; | |
2179 | |
2180 if (enc) { | |
2181 if (enc->len == 4 && ngx_strncmp(enc->data, "none", 4) == 0) { | |
2182 | |
2183 ctx->encoding = NGX_HTTP_SSI_NO_ENCODING; | |
2184 | |
2185 } else if (enc->len == 3 && ngx_strncmp(enc->data, "url", 3) == 0) { | |
2186 | |
2187 ctx->encoding = NGX_HTTP_SSI_URL_ENCODING; | |
2188 | |
2189 } else if (enc->len == 6 && ngx_strncmp(enc->data, "entity", 6) == 0) { | |
2190 | |
2191 ctx->encoding = NGX_HTTP_SSI_ENTITY_ENCODING; | |
2192 | |
2193 } else { | |
2194 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
2195 "unknown encoding \"%V\" in the \"echo\" command", | |
2196 enc); | |
2197 } | |
2198 } | |
2199 | |
2200 switch (ctx->encoding) { | |
2201 | |
2202 case NGX_HTTP_SSI_NO_ENCODING: | |
2203 break; | |
2204 | |
2205 case NGX_HTTP_SSI_URL_ENCODING: | |
2206 len = 2 * ngx_escape_uri(NULL, value->data, value->len, | |
2207 NGX_ESCAPE_HTML); | |
2208 | |
2209 if (len) { | |
2210 p = ngx_palloc(r->pool, value->len + len); | |
2211 if (p == NULL) { | |
2212 return NGX_HTTP_SSI_ERROR; | |
2213 } | |
2214 | |
2215 (void) ngx_escape_uri(p, value->data, value->len, NGX_ESCAPE_HTML); | |
2216 | |
2217 value->len += len; | |
2218 value->data = p; | |
2219 } | |
2220 | |
2221 break; | |
2222 | |
2223 case NGX_HTTP_SSI_ENTITY_ENCODING: | |
2224 len = ngx_escape_html(NULL, value->data, value->len); | |
2225 | |
2226 if (len) { | |
2227 p = ngx_palloc(r->pool, value->len + len); | |
2228 if (p == NULL) { | |
2229 return NGX_HTTP_SSI_ERROR; | |
2230 } | |
2231 | |
2232 (void) ngx_escape_html(p, value->data, value->len); | |
2233 | |
2234 value->len += len; | |
2235 value->data = p; | |
2236 } | |
2237 | |
2238 break; | |
2171 } | 2239 } |
2172 | 2240 |
2173 b = ngx_calloc_buf(r->pool); | 2241 b = ngx_calloc_buf(r->pool); |
2174 if (b == NULL) { | 2242 if (b == NULL) { |
2175 return NGX_HTTP_SSI_ERROR; | 2243 return NGX_HTTP_SSI_ERROR; |
2571 ngx_time_t *tp; | 2639 ngx_time_t *tp; |
2572 struct tm tm; | 2640 struct tm tm; |
2573 char buf[NGX_HTTP_SSI_DATE_LEN]; | 2641 char buf[NGX_HTTP_SSI_DATE_LEN]; |
2574 | 2642 |
2575 v->valid = 1; | 2643 v->valid = 1; |
2576 v->no_cachable = 0; | 2644 v->no_cacheable = 0; |
2577 v->not_found = 0; | 2645 v->not_found = 0; |
2578 | 2646 |
2579 tp = ngx_timeofday(); | 2647 tp = ngx_timeofday(); |
2580 | 2648 |
2581 ctx = ngx_http_get_module_ctx(r, ngx_http_ssi_filter_module); | 2649 ctx = ngx_http_get_module_ctx(r, ngx_http_ssi_filter_module); |
2582 | 2650 |
2583 if (ctx->timefmt.len == sizeof("%s") - 1 | 2651 if (ctx == NULL |
2584 && ctx->timefmt.data[0] == '%' && ctx->timefmt.data[1] == 's') | 2652 || (ctx->timefmt.len == sizeof("%s") - 1 |
2653 && ctx->timefmt.data[0] == '%' && ctx->timefmt.data[1] == 's')) | |
2585 { | 2654 { |
2586 v->data = ngx_palloc(r->pool, NGX_TIME_T_LEN); | 2655 v->data = ngx_palloc(r->pool, NGX_TIME_T_LEN); |
2587 if (v->data == NULL) { | 2656 if (v->data == NULL) { |
2588 return NGX_ERROR; | 2657 return NGX_ERROR; |
2589 } | 2658 } |