comparison src/http/modules/ngx_http_ssi_filter_module.c @ 3581:17995396463d stable-0.7

merge r3454, r3455, r3486, r3496, r3519, r3523: SSI fixes: *) use content type of the parent request in SSI stub block output instead of default one *) SSI %s timefmt has no timezone offset *) change ngx_http_ssi_filter and ngx_http_charset_filter order *) do not store an encoded variable value as a new cached variable value *) fix SSI include stub for valid empty responses *) allow to use $uid_got in SSI and perl module
author Igor Sysoev <igor@sysoev.ru>
date Mon, 07 Jun 2010 09:54:19 +0000
parents ef8cfb09a50b
children 2d21e02fc01d
comparison
equal deleted inserted replaced
3580:667c22171519 3581:17995396463d
2059 "ssi stub output: \"%V?%V\"", &r->uri, &r->args); 2059 "ssi stub output: \"%V?%V\"", &r->uri, &r->args);
2060 2060
2061 out = data; 2061 out = data;
2062 2062
2063 if (!r->header_sent) { 2063 if (!r->header_sent) {
2064 if (ngx_http_set_content_type(r) != NGX_OK) { 2064 r->headers_out.content_type_len =
2065 return NGX_ERROR; 2065 r->parent->headers_out.content_type_len;
2066 } 2066 r->headers_out.content_type = r->parent->headers_out.content_type;
2067 2067
2068 if (ngx_http_send_header(r) == NGX_ERROR) { 2068 if (ngx_http_send_header(r) == NGX_ERROR) {
2069 return NGX_ERROR; 2069 return NGX_ERROR;
2070 } 2070 }
2071 } 2071 }
2159 "unknown encoding \"%V\" in the \"echo\" command", 2159 "unknown encoding \"%V\" in the \"echo\" command",
2160 enc); 2160 enc);
2161 } 2161 }
2162 } 2162 }
2163 2163
2164 p = value->data;
2165
2164 switch (ctx->encoding) { 2166 switch (ctx->encoding) {
2165
2166 case NGX_HTTP_SSI_NO_ENCODING:
2167 break;
2168 2167
2169 case NGX_HTTP_SSI_URL_ENCODING: 2168 case NGX_HTTP_SSI_URL_ENCODING:
2170 len = 2 * ngx_escape_uri(NULL, value->data, value->len, 2169 len = 2 * ngx_escape_uri(NULL, value->data, value->len,
2171 NGX_ESCAPE_HTML); 2170 NGX_ESCAPE_HTML);
2172 2171
2175 if (p == NULL) { 2174 if (p == NULL) {
2176 return NGX_HTTP_SSI_ERROR; 2175 return NGX_HTTP_SSI_ERROR;
2177 } 2176 }
2178 2177
2179 (void) ngx_escape_uri(p, value->data, value->len, NGX_ESCAPE_HTML); 2178 (void) ngx_escape_uri(p, value->data, value->len, NGX_ESCAPE_HTML);
2180 2179 }
2181 value->len += len; 2180
2182 value->data = p; 2181 len += value->len;
2183 }
2184
2185 break; 2182 break;
2186 2183
2187 case NGX_HTTP_SSI_ENTITY_ENCODING: 2184 case NGX_HTTP_SSI_ENTITY_ENCODING:
2188 len = ngx_escape_html(NULL, value->data, value->len); 2185 len = ngx_escape_html(NULL, value->data, value->len);
2189 2186
2192 if (p == NULL) { 2189 if (p == NULL) {
2193 return NGX_HTTP_SSI_ERROR; 2190 return NGX_HTTP_SSI_ERROR;
2194 } 2191 }
2195 2192
2196 (void) ngx_escape_html(p, value->data, value->len); 2193 (void) ngx_escape_html(p, value->data, value->len);
2197 2194 }
2198 value->len += len; 2195
2199 value->data = p; 2196 len += value->len;
2200 } 2197 break;
2201 2198
2199 default: /* NGX_HTTP_SSI_NO_ENCODING */
2200 len = value->len;
2202 break; 2201 break;
2203 } 2202 }
2204 2203
2205 b = ngx_calloc_buf(r->pool); 2204 b = ngx_calloc_buf(r->pool);
2206 if (b == NULL) { 2205 if (b == NULL) {
2211 if (cl == NULL) { 2210 if (cl == NULL) {
2212 return NGX_HTTP_SSI_ERROR; 2211 return NGX_HTTP_SSI_ERROR;
2213 } 2212 }
2214 2213
2215 b->memory = 1; 2214 b->memory = 1;
2216 b->pos = value->data; 2215 b->pos = p;
2217 b->last = value->data + value->len; 2216 b->last = p + len;
2218 2217
2219 cl->buf = b; 2218 cl->buf = b;
2220 cl->next = NULL; 2219 cl->next = NULL;
2221 *ctx->last_out = cl; 2220 *ctx->last_out = cl;
2222 ctx->last_out = &cl->next; 2221 ctx->last_out = &cl->next;
2612 v->data = ngx_pnalloc(r->pool, NGX_TIME_T_LEN); 2611 v->data = ngx_pnalloc(r->pool, NGX_TIME_T_LEN);
2613 if (v->data == NULL) { 2612 if (v->data == NULL) {
2614 return NGX_ERROR; 2613 return NGX_ERROR;
2615 } 2614 }
2616 2615
2617 v->len = ngx_sprintf(v->data, "%T", tp->sec + (gmt ? 0 : tp->gmtoff)) 2616 v->len = ngx_sprintf(v->data, "%T", tp->sec) - v->data;
2618 - v->data;
2619 2617
2620 return NGX_OK; 2618 return NGX_OK;
2621 } 2619 }
2622 2620
2623 if (gmt) { 2621 if (gmt) {