aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2014-01-28 15:40:45 +0400
committerMaxim Dounin <mdounin@mdounin.ru>2014-01-28 15:40:45 +0400
commit1631393f9427892f108d2c6549a568ee1e5ed6bc (patch)
treee98ea4cabe4b785e5ef87905ee109fc0d8339992 /src
parentd700bbefdb97f5d8f158265665b1808108eb50de (diff)
downloadnginx-1631393f9427892f108d2c6549a568ee1e5ed6bc.tar.gz
nginx-1631393f9427892f108d2c6549a568ee1e5ed6bc.zip
SSI: fixed $date_local and $date_gmt without SSI (ticket #230).
If there is no SSI context in a given request at a given time, the $date_local and $date_gmt variables used "%s" format, instead of "%A, %d-%b-%Y %H:%M:%S %Z" documented as the default and used if there is SSI module context and timefmt wasn't modified using the "config" SSI command. While use of these variables outside of the SSI evaluation isn't strictly valid, previous behaviour is certainly inconsistent, hence the fix.
Diffstat (limited to 'src')
-rw-r--r--src/http/modules/ngx_http_ssi_filter_module.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/http/modules/ngx_http_ssi_filter_module.c b/src/http/modules/ngx_http_ssi_filter_module.c
index a53cd1472..aeb1376b7 100644
--- a/src/http/modules/ngx_http_ssi_filter_module.c
+++ b/src/http/modules/ngx_http_ssi_filter_module.c
@@ -213,6 +213,7 @@ static ngx_http_output_body_filter_pt ngx_http_next_body_filter;
static u_char ngx_http_ssi_string[] = "<!--";
static ngx_str_t ngx_http_ssi_none = ngx_string("(none)");
+static ngx_str_t ngx_http_ssi_timefmt = ngx_string("%A, %d-%b-%Y %H:%M:%S %Z");
static ngx_str_t ngx_http_ssi_null_string = ngx_null_string;
@@ -359,7 +360,7 @@ ngx_http_ssi_header_filter(ngx_http_request_t *r)
ctx->params.nalloc = NGX_HTTP_SSI_PARAMS_N;
ctx->params.pool = r->pool;
- ngx_str_set(&ctx->timefmt, "%A, %d-%b-%Y %H:%M:%S %Z");
+ ctx->timefmt = ngx_http_ssi_timefmt;
ngx_str_set(&ctx->errmsg,
"[an error occurred while processing the directive]");
@@ -2720,6 +2721,7 @@ ngx_http_ssi_date_gmt_local_variable(ngx_http_request_t *r,
{
ngx_http_ssi_ctx_t *ctx;
ngx_time_t *tp;
+ ngx_str_t *timefmt;
struct tm tm;
char buf[NGX_HTTP_SSI_DATE_LEN];
@@ -2731,9 +2733,10 @@ ngx_http_ssi_date_gmt_local_variable(ngx_http_request_t *r,
ctx = ngx_http_get_module_ctx(r, ngx_http_ssi_filter_module);
- if (ctx == NULL
- || (ctx->timefmt.len == sizeof("%s") - 1
- && ctx->timefmt.data[0] == '%' && ctx->timefmt.data[1] == 's'))
+ timefmt = ctx ? &ctx->timefmt : &ngx_http_ssi_timefmt;
+
+ if (timefmt->len == sizeof("%s") - 1
+ && timefmt->data[0] == '%' && timefmt->data[1] == 's')
{
v->data = ngx_pnalloc(r->pool, NGX_TIME_T_LEN);
if (v->data == NULL) {
@@ -2752,7 +2755,7 @@ ngx_http_ssi_date_gmt_local_variable(ngx_http_request_t *r,
}
v->len = strftime(buf, NGX_HTTP_SSI_DATE_LEN,
- (char *) ctx->timefmt.data, &tm);
+ (char *) timefmt->data, &tm);
if (v->len == 0) {
return NGX_ERROR;
}