Mercurial > hg > nginx
annotate src/http/modules/ngx_http_ssi_filter_module.c @ 1500:c9c4e96421f1 stable-0.5
r1284 merge:
proxy_ignore_client_abort, fastcgi_ignore_client_abort, and so on were
broken by r1111
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sat, 22 Sep 2007 18:31:26 +0000 |
parents | ccd8734e4a80 |
children | 2d8fab47dd89 |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
4 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
5 |
14
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
6 |
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_core.h> |
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_http.h> |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
10 |
553 | 11 #define NGX_HTTP_SSI_ERROR 1 |
12 | |
13 #define NGX_HTTP_SSI_DATE_LEN 2048 | |
14 | |
15 #define NGX_HTTP_SSI_ADD_PREFIX 1 | |
629 | 16 #define NGX_HTTP_SSI_ADD_ZERO 2 |
635 | 17 #define NGX_HTTP_SSI_EXPR_TEST 4 |
509 | 18 |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
19 |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
20 typedef struct { |
597 | 21 ngx_flag_t enable; |
22 ngx_flag_t silent_errors; | |
23 ngx_flag_t ignore_recycled_buffers; | |
24 | |
25 ngx_array_t *types; /* array of ngx_str_t */ | |
26 | |
27 size_t min_file_chunk; | |
28 size_t value_len; | |
29 } ngx_http_ssi_loc_conf_t; | |
553 | 30 |
31 | |
32 typedef struct { | |
597 | 33 ngx_str_t name; |
611 | 34 ngx_uint_t key; |
597 | 35 ngx_str_t value; |
36 } ngx_http_ssi_var_t; | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
37 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
38 |
667 | 39 typedef struct { |
40 ngx_str_t name; | |
41 ngx_chain_t *bufs; | |
42 ngx_uint_t count; | |
43 } ngx_http_ssi_block_t; | |
44 | |
45 | |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
46 typedef enum { |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
47 ssi_start_state = 0, |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
48 ssi_tag_state, |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
49 ssi_comment0_state, |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
50 ssi_comment1_state, |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
51 ssi_sharp_state, |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
52 ssi_precommand_state, |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
53 ssi_command_state, |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
54 ssi_preparam_state, |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
55 ssi_param_state, |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
56 ssi_preequal_state, |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
57 ssi_prevalue_state, |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
58 ssi_double_quoted_value_state, |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
59 ssi_quoted_value_state, |
497 | 60 ssi_quoted_symbol_state, |
61 ssi_postparam_state, | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
62 ssi_comment_end0_state, |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
63 ssi_comment_end1_state, |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
64 ssi_error_state, |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
65 ssi_error_end0_state, |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
66 ssi_error_end1_state |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
67 } ngx_http_ssi_state_e; |
14
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
68 |
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
69 |
509 | 70 static ngx_int_t ngx_http_ssi_output(ngx_http_request_t *r, |
71 ngx_http_ssi_ctx_t *ctx); | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
72 static ngx_int_t ngx_http_ssi_parse(ngx_http_request_t *r, |
497 | 73 ngx_http_ssi_ctx_t *ctx); |
553 | 74 static ngx_str_t *ngx_http_ssi_get_variable(ngx_http_request_t *r, |
611 | 75 ngx_str_t *name, ngx_uint_t key); |
553 | 76 static ngx_int_t ngx_http_ssi_evaluate_string(ngx_http_request_t *r, |
77 ngx_http_ssi_ctx_t *ctx, ngx_str_t *text, ngx_uint_t flags); | |
78 | |
79 static ngx_int_t ngx_http_ssi_include(ngx_http_request_t *r, | |
80 ngx_http_ssi_ctx_t *ctx, ngx_str_t **params); | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
81 static ngx_int_t ngx_http_ssi_stub_output(ngx_http_request_t *r, void *data, |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
82 ngx_int_t rc); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
83 static ngx_int_t ngx_http_ssi_set_variable(ngx_http_request_t *r, void *data, |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
84 ngx_int_t rc); |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
85 static ngx_int_t ngx_http_ssi_echo(ngx_http_request_t *r, |
497 | 86 ngx_http_ssi_ctx_t *ctx, ngx_str_t **params); |
509 | 87 static ngx_int_t ngx_http_ssi_config(ngx_http_request_t *r, |
88 ngx_http_ssi_ctx_t *ctx, ngx_str_t **params); | |
553 | 89 static ngx_int_t ngx_http_ssi_set(ngx_http_request_t *r, |
509 | 90 ngx_http_ssi_ctx_t *ctx, ngx_str_t **params); |
91 static ngx_int_t ngx_http_ssi_if(ngx_http_request_t *r, | |
92 ngx_http_ssi_ctx_t *ctx, ngx_str_t **params); | |
93 static ngx_int_t ngx_http_ssi_else(ngx_http_request_t *r, | |
94 ngx_http_ssi_ctx_t *ctx, ngx_str_t **params); | |
95 static ngx_int_t ngx_http_ssi_endif(ngx_http_request_t *r, | |
96 ngx_http_ssi_ctx_t *ctx, ngx_str_t **params); | |
667 | 97 static ngx_int_t ngx_http_ssi_block(ngx_http_request_t *r, |
98 ngx_http_ssi_ctx_t *ctx, ngx_str_t **params); | |
99 static ngx_int_t ngx_http_ssi_endblock(ngx_http_request_t *r, | |
100 ngx_http_ssi_ctx_t *ctx, ngx_str_t **params); | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
101 |
573 | 102 static ngx_int_t ngx_http_ssi_date_gmt_local_variable(ngx_http_request_t *r, |
103 ngx_http_variable_value_t *v, uintptr_t gmt); | |
509 | 104 |
527 | 105 static char *ngx_http_ssi_types(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
106 | |
597 | 107 static ngx_int_t ngx_http_ssi_preconfiguration(ngx_conf_t *cf); |
108 static void *ngx_http_ssi_create_main_conf(ngx_conf_t *cf); | |
109 static char *ngx_http_ssi_init_main_conf(ngx_conf_t *cf, void *conf); | |
1169 | 110 static void *ngx_http_ssi_create_loc_conf(ngx_conf_t *cf); |
111 static char *ngx_http_ssi_merge_loc_conf(ngx_conf_t *cf, | |
497 | 112 void *parent, void *child); |
681 | 113 static ngx_int_t ngx_http_ssi_filter_init(ngx_conf_t *cf); |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
114 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
115 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
116 static ngx_command_t ngx_http_ssi_filter_commands[] = { |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
117 |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
118 { ngx_string("ssi"), |
681 | 119 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF |
120 |NGX_CONF_FLAG, | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
121 ngx_conf_set_flag_slot, |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
122 NGX_HTTP_LOC_CONF_OFFSET, |
597 | 123 offsetof(ngx_http_ssi_loc_conf_t, enable), |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
124 NULL }, |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
125 |
497 | 126 { ngx_string("ssi_silent_errors"), |
127 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
128 ngx_conf_set_flag_slot, | |
129 NGX_HTTP_LOC_CONF_OFFSET, | |
597 | 130 offsetof(ngx_http_ssi_loc_conf_t, silent_errors), |
497 | 131 NULL }, |
132 | |
509 | 133 { ngx_string("ssi_ignore_recycled_buffers"), |
134 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
135 ngx_conf_set_flag_slot, | |
136 NGX_HTTP_LOC_CONF_OFFSET, | |
597 | 137 offsetof(ngx_http_ssi_loc_conf_t, ignore_recycled_buffers), |
509 | 138 NULL }, |
139 | |
497 | 140 { ngx_string("ssi_min_file_chunk"), |
141 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
142 ngx_conf_set_size_slot, | |
143 NGX_HTTP_LOC_CONF_OFFSET, | |
597 | 144 offsetof(ngx_http_ssi_loc_conf_t, min_file_chunk), |
497 | 145 NULL }, |
146 | |
589 | 147 { ngx_string("ssi_value_length"), |
148 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
149 ngx_conf_set_size_slot, | |
150 NGX_HTTP_LOC_CONF_OFFSET, | |
597 | 151 offsetof(ngx_http_ssi_loc_conf_t, value_len), |
589 | 152 NULL }, |
153 | |
527 | 154 { ngx_string("ssi_types"), |
155 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, | |
156 ngx_http_ssi_types, | |
157 NGX_HTTP_LOC_CONF_OFFSET, | |
158 0, | |
159 NULL }, | |
160 | |
497 | 161 ngx_null_command |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
162 }; |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
163 |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
164 |
577 | 165 |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
166 static ngx_http_module_t ngx_http_ssi_filter_module_ctx = { |
597 | 167 ngx_http_ssi_preconfiguration, /* preconfiguration */ |
681 | 168 ngx_http_ssi_filter_init, /* postconfiguration */ |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
169 |
597 | 170 ngx_http_ssi_create_main_conf, /* create main configuration */ |
171 ngx_http_ssi_init_main_conf, /* init main configuration */ | |
14
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
172 |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
173 NULL, /* create server configuration */ |
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
174 NULL, /* merge server configuration */ |
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
175 |
1169 | 176 ngx_http_ssi_create_loc_conf, /* create location configuration */ |
177 ngx_http_ssi_merge_loc_conf /* merge location configuration */ | |
577 | 178 }; |
14
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
179 |
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
180 |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
181 ngx_module_t ngx_http_ssi_filter_module = { |
509 | 182 NGX_MODULE_V1, |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
183 &ngx_http_ssi_filter_module_ctx, /* module context */ |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
184 ngx_http_ssi_filter_commands, /* module directives */ |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
185 NGX_HTTP_MODULE, /* module type */ |
541 | 186 NULL, /* init master */ |
681 | 187 NULL, /* init module */ |
541 | 188 NULL, /* init process */ |
189 NULL, /* init thread */ | |
190 NULL, /* exit thread */ | |
191 NULL, /* exit process */ | |
192 NULL, /* exit master */ | |
193 NGX_MODULE_V1_PADDING | |
14
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
194 }; |
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
195 |
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
196 |
569 | 197 static ngx_http_output_header_filter_pt ngx_http_next_header_filter; |
198 static ngx_http_output_body_filter_pt ngx_http_next_body_filter; | |
497 | 199 |
200 | |
201 static u_char ngx_http_ssi_string[] = "<!--"; | |
202 | |
203 static ngx_str_t ngx_http_ssi_none = ngx_string("(none)"); | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
204 static ngx_str_t ngx_http_ssi_null_string = ngx_null_string; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
205 |
16
6ce4755737b4
nginx-0.0.1-2002-09-26-20:50:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
15
diff
changeset
|
206 |
553 | 207 #define NGX_HTTP_SSI_INCLUDE_VIRTUAL 0 |
208 #define NGX_HTTP_SSI_INCLUDE_FILE 1 | |
645 | 209 #define NGX_HTTP_SSI_INCLUDE_WAIT 2 |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
210 #define NGX_HTTP_SSI_INCLUDE_SET 3 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
211 #define NGX_HTTP_SSI_INCLUDE_STUB 4 |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
212 |
509 | 213 #define NGX_HTTP_SSI_ECHO_VAR 0 |
214 #define NGX_HTTP_SSI_ECHO_DEFAULT 1 | |
215 | |
547 | 216 #define NGX_HTTP_SSI_CONFIG_ERRMSG 0 |
217 #define NGX_HTTP_SSI_CONFIG_TIMEFMT 1 | |
509 | 218 |
553 | 219 #define NGX_HTTP_SSI_SET_VAR 0 |
220 #define NGX_HTTP_SSI_SET_VALUE 1 | |
509 | 221 |
222 #define NGX_HTTP_SSI_IF_EXPR 0 | |
223 | |
667 | 224 #define NGX_HTTP_SSI_BLOCK_NAME 0 |
225 | |
497 | 226 |
553 | 227 static ngx_http_ssi_param_t ngx_http_ssi_include_params[] = { |
597 | 228 { ngx_string("virtual"), NGX_HTTP_SSI_INCLUDE_VIRTUAL, 0, 0 }, |
229 { ngx_string("file"), NGX_HTTP_SSI_INCLUDE_FILE, 0, 0 }, | |
645 | 230 { ngx_string("wait"), NGX_HTTP_SSI_INCLUDE_WAIT, 0, 0 }, |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
231 { ngx_string("set"), NGX_HTTP_SSI_INCLUDE_SET, 0, 0 }, |
667 | 232 { ngx_string("stub"), NGX_HTTP_SSI_INCLUDE_STUB, 0, 0 }, |
597 | 233 { ngx_null_string, 0, 0, 0 } |
553 | 234 }; |
235 | |
236 | |
497 | 237 static ngx_http_ssi_param_t ngx_http_ssi_echo_params[] = { |
597 | 238 { ngx_string("var"), NGX_HTTP_SSI_ECHO_VAR, 1, 0 }, |
239 { ngx_string("default"), NGX_HTTP_SSI_ECHO_DEFAULT, 0, 0 }, | |
240 { ngx_null_string, 0, 0, 0 } | |
497 | 241 }; |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
242 |
509 | 243 |
244 static ngx_http_ssi_param_t ngx_http_ssi_config_params[] = { | |
597 | 245 { ngx_string("errmsg"), NGX_HTTP_SSI_CONFIG_ERRMSG, 0, 0 }, |
246 { ngx_string("timefmt"), NGX_HTTP_SSI_CONFIG_TIMEFMT, 0, 0 }, | |
247 { ngx_null_string, 0, 0, 0 } | |
509 | 248 }; |
249 | |
250 | |
553 | 251 static ngx_http_ssi_param_t ngx_http_ssi_set_params[] = { |
597 | 252 { ngx_string("var"), NGX_HTTP_SSI_SET_VAR, 1, 0 }, |
253 { ngx_string("value"), NGX_HTTP_SSI_SET_VALUE, 1, 0 }, | |
254 { ngx_null_string, 0, 0, 0 } | |
553 | 255 }; |
256 | |
257 | |
509 | 258 static ngx_http_ssi_param_t ngx_http_ssi_if_params[] = { |
597 | 259 { ngx_string("expr"), NGX_HTTP_SSI_IF_EXPR, 1, 0 }, |
260 { ngx_null_string, 0, 0, 0 } | |
509 | 261 }; |
262 | |
263 | |
667 | 264 static ngx_http_ssi_param_t ngx_http_ssi_block_params[] = { |
265 { ngx_string("name"), NGX_HTTP_SSI_BLOCK_NAME, 1, 0 }, | |
266 { ngx_null_string, 0, 0, 0 } | |
267 }; | |
268 | |
269 | |
509 | 270 static ngx_http_ssi_param_t ngx_http_ssi_no_params[] = { |
597 | 271 { ngx_null_string, 0, 0, 0 } |
509 | 272 }; |
273 | |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
274 |
497 | 275 static ngx_http_ssi_command_t ngx_http_ssi_commands[] = { |
553 | 276 { ngx_string("include"), ngx_http_ssi_include, |
667 | 277 ngx_http_ssi_include_params, 0, 0, 1 }, |
278 { ngx_string("echo"), ngx_http_ssi_echo, | |
279 ngx_http_ssi_echo_params, 0, 0, 0 }, | |
509 | 280 { ngx_string("config"), ngx_http_ssi_config, |
667 | 281 ngx_http_ssi_config_params, 0, 0, 0 }, |
282 { ngx_string("set"), ngx_http_ssi_set, ngx_http_ssi_set_params, 0, 0, 0 }, | |
283 | |
284 { ngx_string("if"), ngx_http_ssi_if, ngx_http_ssi_if_params, 0, 0, 0 }, | |
629 | 285 { ngx_string("elif"), ngx_http_ssi_if, ngx_http_ssi_if_params, |
667 | 286 NGX_HTTP_SSI_COND_IF, 0, 0 }, |
629 | 287 { ngx_string("else"), ngx_http_ssi_else, ngx_http_ssi_no_params, |
667 | 288 NGX_HTTP_SSI_COND_IF, 0, 0 }, |
629 | 289 { ngx_string("endif"), ngx_http_ssi_endif, ngx_http_ssi_no_params, |
667 | 290 NGX_HTTP_SSI_COND_ELSE, 0, 0 }, |
291 | |
292 { ngx_string("block"), ngx_http_ssi_block, | |
293 ngx_http_ssi_block_params, 0, 0, 0 }, | |
294 { ngx_string("endblock"), ngx_http_ssi_endblock, | |
295 ngx_http_ssi_no_params, 0, 1, 0 }, | |
296 | |
297 { ngx_null_string, NULL, NULL, 0, 0, 0 } | |
497 | 298 }; |
299 | |
300 | |
509 | 301 static ngx_http_variable_t ngx_http_ssi_vars[] = { |
302 | |
637 | 303 { ngx_string("date_local"), NULL, ngx_http_ssi_date_gmt_local_variable, 0, |
533 | 304 NGX_HTTP_VAR_NOCACHABLE, 0 }, |
509 | 305 |
637 | 306 { ngx_string("date_gmt"), NULL, ngx_http_ssi_date_gmt_local_variable, 1, |
533 | 307 NGX_HTTP_VAR_NOCACHABLE, 0 }, |
509 | 308 |
637 | 309 { ngx_null_string, NULL, NULL, 0, 0, 0 } |
509 | 310 }; |
311 | |
312 | |
313 | |
497 | 314 static ngx_int_t |
315 ngx_http_ssi_header_filter(ngx_http_request_t *r) | |
129
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
316 { |
597 | 317 ngx_uint_t i; |
318 ngx_str_t *type; | |
319 ngx_http_ssi_ctx_t *ctx; | |
320 ngx_http_ssi_loc_conf_t *slcf; | |
321 | |
322 slcf = ngx_http_get_module_loc_conf(r, ngx_http_ssi_filter_module); | |
323 | |
324 if (!slcf->enable | |
577 | 325 || r->headers_out.content_type.len == 0 |
326 || r->headers_out.content_length_n == 0) | |
247
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
243
diff
changeset
|
327 { |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
243
diff
changeset
|
328 return ngx_http_next_header_filter(r); |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
243
diff
changeset
|
329 } |
008276b9e061
nginx-0.0.1-2004-02-01-11:10:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
243
diff
changeset
|
330 |
497 | 331 |
597 | 332 type = slcf->types->elts; |
333 for (i = 0; i < slcf->types->nelts; i++) { | |
527 | 334 if (r->headers_out.content_type.len >= type[i].len |
335 && ngx_strncasecmp(r->headers_out.content_type.data, | |
336 type[i].data, type[i].len) == 0) | |
337 { | |
338 goto found; | |
339 } | |
340 } | |
341 | |
342 return ngx_http_next_header_filter(r); | |
343 | |
344 | |
345 found: | |
346 | |
499 | 347 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_ssi_ctx_t)); |
348 if (ctx == NULL) { | |
497 | 349 return NGX_ERROR; |
350 } | |
351 | |
352 ngx_http_set_ctx(r, ctx, ngx_http_ssi_filter_module); | |
353 | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
354 |
597 | 355 ctx->value_len = slcf->value_len; |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
356 ctx->last_out = &ctx->out; |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
357 |
509 | 358 ctx->output = 1; |
359 | |
497 | 360 ctx->params.elts = ctx->params_array; |
361 ctx->params.size = sizeof(ngx_table_elt_t); | |
362 ctx->params.nalloc = NGX_HTTP_SSI_PARAMS_N; | |
363 ctx->params.pool = r->pool; | |
364 | |
509 | 365 ctx->timefmt.len = sizeof("%A, %d-%b-%Y %H:%M:%S %Z") - 1; |
366 ctx->timefmt.data = (u_char *) "%A, %d-%b-%Y %H:%M:%S %Z"; | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
367 |
547 | 368 ctx->errmsg.len = |
369 sizeof("[an error occurred while processing the directive]") - 1; | |
370 ctx->errmsg.data = (u_char *) | |
371 "[an error occurred while processing the directive]"; | |
372 | |
497 | 373 r->filter_need_in_memory = 1; |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
374 |
597 | 375 if (r == r->main) { |
577 | 376 ngx_http_clear_content_length(r); |
377 ngx_http_clear_last_modified(r); | |
509 | 378 } |
379 | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
380 return ngx_http_next_header_filter(r); |
129
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
381 } |
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
382 |
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
383 |
497 | 384 static ngx_int_t |
385 ngx_http_ssi_body_filter(ngx_http_request_t *r, ngx_chain_t *in) | |
15
cbb38b60495c
nginx-0.0.1-2002-09-18-20:32:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
14
diff
changeset
|
386 { |
667 | 387 size_t len; |
597 | 388 ngx_int_t rc; |
389 ngx_buf_t *b; | |
390 ngx_uint_t i, index; | |
667 | 391 ngx_chain_t *cl, **ll; |
597 | 392 ngx_table_elt_t *param; |
767
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
393 ngx_http_request_t *pr; |
667 | 394 ngx_http_ssi_ctx_t *ctx, *mctx; |
395 ngx_http_ssi_block_t *bl; | |
597 | 396 ngx_http_ssi_param_t *prm; |
397 ngx_http_ssi_command_t *cmd; | |
398 ngx_http_ssi_loc_conf_t *slcf; | |
399 ngx_http_ssi_main_conf_t *smcf; | |
599 | 400 ngx_str_t *params[NGX_HTTP_SSI_MAX_PARAMS + 1]; |
16
6ce4755737b4
nginx-0.0.1-2002-09-26-20:50:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
15
diff
changeset
|
401 |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
402 ctx = ngx_http_get_module_ctx(r, ngx_http_ssi_filter_module); |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
403 |
645 | 404 if (ctx == NULL |
405 || (in == NULL | |
406 && ctx->buf == NULL | |
407 && ctx->in == NULL | |
408 && ctx->busy == NULL)) | |
409 { | |
243
bf2faf694c19
nginx-0.0.1-2004-01-28-23:38:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
242
diff
changeset
|
410 return ngx_http_next_body_filter(r, in); |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
411 } |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
412 |
497 | 413 /* add the incoming chain to the chain ctx->in */ |
129
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
414 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
415 if (in) { |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
416 if (ngx_chain_add_copy(r->pool, &ctx->in, in) == NGX_ERROR) { |
129
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
417 return NGX_ERROR; |
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
418 } |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
419 } |
129
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
420 |
645 | 421 if (ctx->wait) { |
767
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
422 if (r->connection->data != r) { |
645 | 423 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
424 "http ssi filter \"%V\" wait", &r->uri); | |
425 return NGX_AGAIN; | |
426 } | |
427 | |
767
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
428 for (pr = ctx->wait->parent; pr; pr = pr->parent) { |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
429 if (pr == r) { |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
430 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
431 "http ssi filter \"%V\" flush", &r->uri); |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
432 |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
433 rc = ngx_http_next_body_filter(r, NULL); |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
434 |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
435 if (ctx->wait->done) { |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
436 ctx->wait = NULL; |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
437 } |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
438 |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
439 if (rc == NGX_ERROR || rc == NGX_AGAIN) { |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
440 return rc; |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
441 } |
1326
ccd8734e4a80
r1318, r1319, r1320, r1321 merge:
Igor Sysoev <igor@sysoev.ru>
parents:
1269
diff
changeset
|
442 |
ccd8734e4a80
r1318, r1319, r1320, r1321 merge:
Igor Sysoev <igor@sysoev.ru>
parents:
1269
diff
changeset
|
443 break; |
767
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
444 } |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
445 } |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
446 |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
447 if (ctx->wait == r) { |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
448 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
449 "http ssi filter \"%V\" continue", &r->uri); |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
450 ctx->wait = NULL; |
cad7543dc419
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
765
diff
changeset
|
451 } |
645 | 452 } |
453 | |
597 | 454 slcf = ngx_http_get_module_loc_conf(r, ngx_http_ssi_filter_module); |
129
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
455 |
509 | 456 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
457 "http ssi filter \"%V\"", &r->uri); | |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
458 |
499 | 459 while (ctx->in || ctx->buf) { |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
460 |
499 | 461 if (ctx->buf == NULL ){ |
462 ctx->buf = ctx->in->buf; | |
463 ctx->in = ctx->in->next; | |
464 ctx->pos = ctx->buf->pos; | |
465 } | |
497 | 466 |
467 if (ctx->state == ssi_start_state) { | |
468 ctx->copy_start = ctx->pos; | |
469 ctx->copy_end = ctx->pos; | |
129
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
470 } |
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
471 |
499 | 472 b = NULL; |
473 | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
474 while (ctx->pos < ctx->buf->last) { |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
475 |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
476 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
477 "saved: %d state: %d", ctx->saved, ctx->state); |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
478 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
479 rc = ngx_http_ssi_parse(r, ctx); |
129
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
480 |
497 | 481 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
482 "parse: %d, looked: %d %p-%p", | |
483 rc, ctx->looked, ctx->copy_start, ctx->copy_end); | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
484 |
497 | 485 if (rc == NGX_ERROR) { |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
486 return rc; |
497 | 487 } |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
488 |
497 | 489 if (ctx->copy_start != ctx->copy_end) { |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
490 |
509 | 491 if (ctx->output) { |
492 | |
493 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
494 "saved: %d", ctx->saved); | |
495 | |
496 if (ctx->saved) { | |
497 | |
498 if (ctx->free) { | |
499 cl = ctx->free; | |
500 ctx->free = ctx->free->next; | |
501 b = cl->buf; | |
502 ngx_memzero(b, sizeof(ngx_buf_t)); | |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
503 |
509 | 504 } else { |
505 b = ngx_calloc_buf(r->pool); | |
506 if (b == NULL) { | |
507 return NGX_ERROR; | |
508 } | |
509 | |
510 cl = ngx_alloc_chain_link(r->pool); | |
511 if (cl == NULL) { | |
512 return NGX_ERROR; | |
513 } | |
514 | |
515 cl->buf = b; | |
516 } | |
517 | |
518 b->memory = 1; | |
519 b->pos = ngx_http_ssi_string; | |
520 b->last = ngx_http_ssi_string + ctx->saved; | |
521 | |
522 *ctx->last_out = cl; | |
523 ctx->last_out = &cl->next; | |
524 | |
525 ctx->saved = 0; | |
526 } | |
499 | 527 |
528 if (ctx->free) { | |
529 cl = ctx->free; | |
530 ctx->free = ctx->free->next; | |
531 b = cl->buf; | |
532 | |
533 } else { | |
509 | 534 b = ngx_alloc_buf(r->pool); |
499 | 535 if (b == NULL) { |
536 return NGX_ERROR; | |
537 } | |
538 | |
539 cl = ngx_alloc_chain_link(r->pool); | |
540 if (cl == NULL) { | |
541 return NGX_ERROR; | |
542 } | |
543 | |
544 cl->buf = b; | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
545 } |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
546 |
509 | 547 ngx_memcpy(b, ctx->buf, sizeof(ngx_buf_t)); |
548 | |
513 | 549 b->pos = ctx->copy_start; |
550 b->last = ctx->copy_end; | |
551 b->shadow = NULL; | |
509 | 552 b->last_buf = 0; |
553 b->recycled = 0; | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
554 |
509 | 555 if (b->in_file) { |
597 | 556 if (slcf->min_file_chunk < (size_t) (b->last - b->pos)) |
509 | 557 { |
558 b->file_last = b->file_pos + (b->last - b->start); | |
559 b->file_pos += b->pos - b->start; | |
560 | |
561 } else { | |
562 b->in_file = 0; | |
563 } | |
564 } | |
565 | |
566 cl->next = NULL; | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
567 *ctx->last_out = cl; |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
568 ctx->last_out = &cl->next; |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
569 |
509 | 570 } else { |
667 | 571 if (ctx->block |
572 && ctx->saved + (ctx->copy_end - ctx->copy_start)) | |
573 { | |
574 b = ngx_create_temp_buf(r->pool, | |
575 ctx->saved + (ctx->copy_end - ctx->copy_start)); | |
576 | |
577 if (b == NULL) { | |
578 return NGX_ERROR; | |
579 } | |
580 | |
581 if (ctx->saved) { | |
582 b->last = ngx_cpymem(b->pos, ngx_http_ssi_string, | |
583 ctx->saved); | |
584 } | |
585 | |
586 b->last = ngx_cpymem(b->last, ctx->copy_start, | |
587 ctx->copy_end - ctx->copy_start); | |
588 | |
589 cl = ngx_alloc_chain_link(r->pool); | |
590 if (cl == NULL) { | |
591 return NGX_ERROR; | |
592 } | |
593 | |
594 cl->buf = b; | |
595 cl->next = NULL; | |
596 | |
597 b = NULL; | |
598 | |
599 mctx = ngx_http_get_module_ctx(r->main, | |
600 ngx_http_ssi_filter_module); | |
601 bl = mctx->blocks->elts; | |
602 for (ll = &bl[mctx->blocks->nelts - 1].bufs; | |
603 *ll; | |
604 ll = &(*ll)->next) | |
605 { | |
606 /* void */ | |
607 } | |
608 | |
609 *ll = cl; | |
610 } | |
611 | |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
612 ctx->saved = 0; |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
613 } |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
614 } |
497 | 615 |
616 if (ctx->state == ssi_start_state) { | |
617 ctx->copy_start = ctx->pos; | |
618 ctx->copy_end = ctx->pos; | |
240
725129fdd524
nginx-0.0.1-2004-01-26-20:22:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
239
diff
changeset
|
619 |
497 | 620 } else { |
621 ctx->copy_start = NULL; | |
622 ctx->copy_end = NULL; | |
623 } | |
624 | |
625 if (rc == NGX_AGAIN) { | |
626 continue; | |
627 } | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
628 |
497 | 629 |
573 | 630 b = NULL; |
631 | |
497 | 632 if (rc == NGX_OK) { |
633 | |
597 | 634 smcf = ngx_http_get_module_main_conf(r, |
635 ngx_http_ssi_filter_module); | |
636 | |
637 cmd = ngx_hash_find(&smcf->hash, ctx->key, ctx->command.data, | |
638 ctx->command.len); | |
639 | |
640 if (cmd == NULL) { | |
641 if (ctx->output) { | |
642 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
643 "invalid SSI command: \"%V\"", | |
644 &ctx->command); | |
645 goto ssi_error; | |
497 | 646 } |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
647 |
597 | 648 continue; |
497 | 649 } |
650 | |
629 | 651 if (cmd->conditional |
652 && (ctx->conditional == 0 | |
653 || ctx->conditional > cmd->conditional)) | |
654 { | |
655 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
656 "invalid context of SSI command: \"%V\"", | |
657 &ctx->command); | |
658 goto ssi_error; | |
659 } | |
660 | |
667 | 661 if (!ctx->output && !cmd->block) { |
662 | |
663 if (ctx->block) { | |
664 | |
665 /* reconstruct the SSI command text */ | |
666 | |
667 len = 5 + ctx->command.len + 4; | |
668 | |
669 param = ctx->params.elts; | |
670 for (i = 0; i < ctx->params.nelts; i++) { | |
671 len += 1 + param[i].key.len + 2 | |
672 + param[i].value.len + 1; | |
673 } | |
674 | |
675 b = ngx_create_temp_buf(r->pool, len); | |
676 | |
677 if (b == NULL) { | |
678 return NGX_ERROR; | |
679 } | |
680 | |
681 cl = ngx_alloc_chain_link(r->pool); | |
682 if (cl == NULL) { | |
683 return NGX_ERROR; | |
684 } | |
685 | |
686 cl->buf = b; | |
687 cl->next = NULL; | |
688 | |
689 *b->last++ = '<'; | |
690 *b->last++ = '!'; | |
691 *b->last++ = '-'; | |
692 *b->last++ = '-'; | |
693 *b->last++ = '#'; | |
694 | |
695 b->last = ngx_cpymem(b->last, ctx->command.data, | |
696 ctx->command.len); | |
697 | |
698 for (i = 0; i < ctx->params.nelts; i++) { | |
699 *b->last++ = ' '; | |
700 b->last = ngx_cpymem(b->last, param[i].key.data, | |
701 param[i].key.len); | |
702 *b->last++ = '='; | |
703 *b->last++ = '"'; | |
704 b->last = ngx_cpymem(b->last, param[i].value.data, | |
705 param[i].value.len); | |
706 *b->last++ = '"'; | |
707 } | |
708 | |
709 *b->last++ = ' '; | |
710 *b->last++ = '-'; | |
711 *b->last++ = '-'; | |
712 *b->last++ = '>'; | |
713 | |
714 mctx = ngx_http_get_module_ctx(r->main, | |
715 ngx_http_ssi_filter_module); | |
716 bl = mctx->blocks->elts; | |
717 for (ll = &bl[mctx->blocks->nelts - 1].bufs; | |
718 *ll; | |
719 ll = &(*ll)->next) | |
720 { | |
721 /* void */ | |
722 } | |
723 | |
724 *ll = cl; | |
725 | |
726 b = NULL; | |
727 | |
728 continue; | |
729 } | |
730 | |
731 if (cmd->conditional == 0) { | |
732 continue; | |
733 } | |
509 | 734 } |
735 | |
597 | 736 if (ctx->params.nelts > NGX_HTTP_SSI_MAX_PARAMS) { |
737 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
738 "too many SSI command paramters: \"%V\"", | |
739 &ctx->command); | |
740 goto ssi_error; | |
741 } | |
742 | |
497 | 743 ngx_memzero(params, |
599 | 744 (NGX_HTTP_SSI_MAX_PARAMS + 1) * sizeof(ngx_str_t *)); |
497 | 745 |
746 param = ctx->params.elts; | |
747 | |
748 for (i = 0; i < ctx->params.nelts; i++) { | |
749 | |
750 for (prm = cmd->params; prm->name.len; prm++) { | |
751 | |
752 if (param[i].key.len != prm->name.len | |
753 || ngx_strncmp(param[i].key.data, prm->name.data, | |
754 prm->name.len) != 0) | |
755 { | |
756 continue; | |
757 } | |
758 | |
597 | 759 if (!prm->multiple) { |
760 if (params[prm->index]) { | |
761 ngx_log_error(NGX_LOG_ERR, | |
762 r->connection->log, 0, | |
763 "duplicate \"%V\" parameter " | |
764 "in \"%V\" SSI command", | |
765 ¶m[i].key, &ctx->command); | |
766 | |
767 goto ssi_error; | |
768 } | |
769 | |
770 params[prm->index] = ¶m[i].value; | |
771 | |
772 break; | |
497 | 773 } |
774 | |
597 | 775 for (index = prm->index; params[index]; index++) { |
776 /* void */ | |
777 } | |
778 | |
779 params[index] = ¶m[i].value; | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
780 |
497 | 781 break; |
782 } | |
783 | |
784 if (prm->name.len == 0) { | |
785 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
786 "invalid parameter name: \"%V\" " | |
787 "in \"%V\" SSI command", | |
788 ¶m[i].key, &ctx->command); | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
789 |
497 | 790 goto ssi_error; |
791 } | |
792 } | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
793 |
497 | 794 for (prm = cmd->params; prm->name.len; prm++) { |
795 if (prm->mandatory && params[prm->index] == 0) { | |
796 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
797 "mandatory \"%V\" parameter is absent " | |
798 "in \"%V\" SSI command", | |
799 &prm->name, &ctx->command); | |
800 | |
801 goto ssi_error; | |
802 } | |
803 } | |
804 | |
1269 | 805 if (cmd->flush) { |
806 | |
807 if (ctx->out) { | |
808 rc = ngx_http_ssi_output(r, ctx); | |
809 | |
810 } else { | |
811 rc = ngx_http_next_body_filter(r, NULL); | |
812 } | |
509 | 813 |
814 if (rc == NGX_ERROR) { | |
815 return NGX_ERROR; | |
816 } | |
817 } | |
818 | |
569 | 819 rc = cmd->handler(r, ctx, params); |
820 | |
821 if (rc == NGX_OK) { | |
497 | 822 continue; |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
823 } |
583 | 824 |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
825 if (rc == NGX_DONE || rc == NGX_AGAIN || rc == NGX_ERROR) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
826 return rc; |
583 | 827 } |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
828 } |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
829 |
497 | 830 |
831 /* rc == NGX_HTTP_SSI_ERROR */ | |
832 | |
499 | 833 ssi_error: |
497 | 834 |
597 | 835 if (slcf->silent_errors) { |
497 | 836 continue; |
837 } | |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
838 |
499 | 839 if (ctx->free) { |
840 cl = ctx->free; | |
841 ctx->free = ctx->free->next; | |
842 b = cl->buf; | |
843 ngx_memzero(b, sizeof(ngx_buf_t)); | |
844 | |
845 } else { | |
846 b = ngx_calloc_buf(r->pool); | |
847 if (b == NULL) { | |
848 return NGX_ERROR; | |
849 } | |
850 | |
851 cl = ngx_alloc_chain_link(r->pool); | |
852 if (cl == NULL) { | |
853 return NGX_ERROR; | |
854 } | |
855 | |
856 cl->buf = b; | |
497 | 857 } |
16
6ce4755737b4
nginx-0.0.1-2002-09-26-20:50:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
15
diff
changeset
|
858 |
497 | 859 b->memory = 1; |
547 | 860 b->pos = ctx->errmsg.data; |
861 b->last = ctx->errmsg.data + ctx->errmsg.len; | |
16
6ce4755737b4
nginx-0.0.1-2002-09-26-20:50:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
15
diff
changeset
|
862 |
497 | 863 cl->next = NULL; |
864 *ctx->last_out = cl; | |
865 ctx->last_out = &cl->next; | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
866 |
497 | 867 continue; |
868 } | |
869 | |
710
6875ee9f93c7
ssi did work with memcached and nonbuffered responses
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
870 if (ctx->buf->last_buf || ngx_buf_in_memory(ctx->buf)) { |
499 | 871 if (b == NULL) { |
872 if (ctx->free) { | |
873 cl = ctx->free; | |
874 ctx->free = ctx->free->next; | |
875 b = cl->buf; | |
876 ngx_memzero(b, sizeof(ngx_buf_t)); | |
877 | |
878 } else { | |
879 b = ngx_calloc_buf(r->pool); | |
880 if (b == NULL) { | |
881 return NGX_ERROR; | |
882 } | |
497 | 883 |
499 | 884 cl = ngx_alloc_chain_link(r->pool); |
885 if (cl == NULL) { | |
886 return NGX_ERROR; | |
887 } | |
888 | |
889 cl->buf = b; | |
890 } | |
891 | |
509 | 892 b->sync = 1; |
893 | |
499 | 894 cl->next = NULL; |
895 *ctx->last_out = cl; | |
896 ctx->last_out = &cl->next; | |
897 } | |
898 | |
899 b->last_buf = ctx->buf->last_buf; | |
900 b->shadow = ctx->buf; | |
509 | 901 |
597 | 902 if (slcf->ignore_recycled_buffers == 0) { |
509 | 903 b->recycled = ctx->buf->recycled; |
904 } | |
497 | 905 } |
906 | |
499 | 907 ctx->buf = NULL; |
908 | |
497 | 909 ctx->saved = ctx->looked; |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
910 } |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
911 |
499 | 912 if (ctx->out == NULL && ctx->busy == NULL) { |
497 | 913 return NGX_OK; |
129
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
914 } |
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
915 |
509 | 916 return ngx_http_ssi_output(r, ctx); |
917 } | |
918 | |
919 | |
920 static ngx_int_t | |
921 ngx_http_ssi_output(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx) | |
922 { | |
923 ngx_int_t rc; | |
924 ngx_buf_t *b; | |
925 ngx_chain_t *cl; | |
926 | |
641 | 927 #if 1 |
928 b = NULL; | |
929 for (cl = ctx->out; cl; cl = cl->next) { | |
643 | 930 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
931 "ssi out: %p %p", cl->buf, cl->buf->pos); | |
641 | 932 if (cl->buf == b) { |
933 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, | |
934 "the same buf was used in ssi"); | |
935 ngx_debug_point(); | |
936 return NGX_ERROR; | |
937 } | |
938 b = cl->buf; | |
939 } | |
940 #endif | |
941 | |
497 | 942 rc = ngx_http_next_body_filter(r, ctx->out); |
129
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
943 |
499 | 944 if (ctx->busy == NULL) { |
945 ctx->busy = ctx->out; | |
946 | |
947 } else { | |
948 for (cl = ctx->busy; cl->next; cl = cl->next) { /* void */ } | |
949 cl->next = ctx->out; | |
950 } | |
951 | |
497 | 952 ctx->out = NULL; |
953 ctx->last_out = &ctx->out; | |
129
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
954 |
499 | 955 while (ctx->busy) { |
956 | |
657 | 957 cl = ctx->busy; |
958 b = cl->buf; | |
499 | 959 |
960 if (ngx_buf_size(b) != 0) { | |
961 break; | |
962 } | |
963 | |
964 #if (NGX_HAVE_WRITE_ZEROCOPY) | |
965 if (b->zerocopy_busy) { | |
966 break; | |
967 } | |
968 #endif | |
969 | |
970 if (b->shadow) { | |
971 b->shadow->pos = b->shadow->last; | |
972 } | |
973 | |
974 ctx->busy = cl->next; | |
645 | 975 |
976 if (ngx_buf_in_memory(b) || b->in_file) { | |
977 /* add data bufs only to the free buf chain */ | |
978 | |
979 cl->next = ctx->free; | |
980 ctx->free = cl; | |
981 } | |
499 | 982 } |
983 | |
829
362d156f0278
high level HTTP buffered flags should be on per-subrequest basis,
Igor Sysoev <igor@sysoev.ru>
parents:
787
diff
changeset
|
984 if (ctx->in || ctx->buf) { |
362d156f0278
high level HTTP buffered flags should be on per-subrequest basis,
Igor Sysoev <igor@sysoev.ru>
parents:
787
diff
changeset
|
985 r->buffered |= NGX_HTTP_SSI_BUFFERED; |
362d156f0278
high level HTTP buffered flags should be on per-subrequest basis,
Igor Sysoev <igor@sysoev.ru>
parents:
787
diff
changeset
|
986 |
362d156f0278
high level HTTP buffered flags should be on per-subrequest basis,
Igor Sysoev <igor@sysoev.ru>
parents:
787
diff
changeset
|
987 } else { |
362d156f0278
high level HTTP buffered flags should be on per-subrequest basis,
Igor Sysoev <igor@sysoev.ru>
parents:
787
diff
changeset
|
988 r->buffered &= ~NGX_HTTP_SSI_BUFFERED; |
362d156f0278
high level HTTP buffered flags should be on per-subrequest basis,
Igor Sysoev <igor@sysoev.ru>
parents:
787
diff
changeset
|
989 } |
362d156f0278
high level HTTP buffered flags should be on per-subrequest basis,
Igor Sysoev <igor@sysoev.ru>
parents:
787
diff
changeset
|
990 |
497 | 991 return rc; |
129
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
992 } |
7a886b9a67dc
nginx-0.0.1-2003-08-10-20:14:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
128
diff
changeset
|
993 |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
994 |
489 | 995 static ngx_int_t |
996 ngx_http_ssi_parse(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx) | |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
997 { |
609 | 998 u_char *p, *value, *last, *copy_end, ch; |
497 | 999 size_t looked; |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
1000 ngx_http_ssi_state_e state; |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1001 |
497 | 1002 state = ctx->state; |
1003 looked = ctx->looked; | |
1004 last = ctx->buf->last; | |
1005 copy_end = ctx->copy_end; | |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1006 |
497 | 1007 for (p = ctx->pos; p < last; p++) { |
489 | 1008 |
1009 ch = *p; | |
1010 | |
1011 if (state == ssi_start_state) { | |
1012 | |
1013 /* the tight loop */ | |
1014 | |
499 | 1015 for ( ;; ) { |
1016 if (ch == '<') { | |
1017 copy_end = p; | |
1018 looked = 1; | |
1019 state = ssi_tag_state; | |
1020 | |
1021 goto tag_started; | |
489 | 1022 } |
1023 | |
499 | 1024 if (++p == last) { |
1025 break; | |
1026 } | |
497 | 1027 |
499 | 1028 ch = *p; |
489 | 1029 } |
1030 | |
1262 | 1031 ctx->state = state; |
497 | 1032 ctx->pos = p; |
1033 ctx->looked = looked; | |
1034 ctx->copy_end = p; | |
489 | 1035 |
497 | 1036 if (ctx->copy_start == NULL) { |
1037 ctx->copy_start = ctx->buf->pos; | |
489 | 1038 } |
497 | 1039 |
1040 return NGX_AGAIN; | |
1041 | |
499 | 1042 tag_started: |
1043 | |
497 | 1044 continue; |
489 | 1045 } |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1046 |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
1047 switch (state) { |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1048 |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
1049 case ssi_start_state: |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1050 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1051 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1052 case ssi_tag_state: |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1053 switch (ch) { |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1054 case '!': |
497 | 1055 looked = 2; |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1056 state = ssi_comment0_state; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1057 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1058 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1059 case '<': |
497 | 1060 copy_end = p; |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1061 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1062 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1063 default: |
497 | 1064 copy_end = p; |
1065 looked = 0; | |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1066 state = ssi_start_state; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1067 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1068 } |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1069 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1070 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1071 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1072 case ssi_comment0_state: |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1073 switch (ch) { |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1074 case '-': |
497 | 1075 looked = 3; |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1076 state = ssi_comment1_state; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1077 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1078 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1079 case '<': |
497 | 1080 copy_end = p; |
1081 looked = 1; | |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1082 state = ssi_tag_state; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1083 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1084 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1085 default: |
497 | 1086 copy_end = p; |
1087 looked = 0; | |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1088 state = ssi_start_state; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1089 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1090 } |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1091 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1092 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1093 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1094 case ssi_comment1_state: |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1095 switch (ch) { |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1096 case '-': |
497 | 1097 looked = 4; |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1098 state = ssi_sharp_state; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1099 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1100 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1101 case '<': |
497 | 1102 copy_end = p; |
1103 looked = 1; | |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1104 state = ssi_tag_state; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1105 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1106 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1107 default: |
497 | 1108 copy_end = p; |
1109 looked = 0; | |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1110 state = ssi_start_state; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1111 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1112 } |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1113 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1114 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1115 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1116 case ssi_sharp_state: |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1117 switch (ch) { |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1118 case '#': |
659 | 1119 if (p - ctx->pos < 4) { |
1120 ctx->saved = 0; | |
1121 } | |
497 | 1122 looked = 0; |
1123 state = ssi_precommand_state; | |
489 | 1124 break; |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1125 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1126 case '<': |
497 | 1127 copy_end = p; |
1128 looked = 1; | |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1129 state = ssi_tag_state; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1130 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1131 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1132 default: |
497 | 1133 copy_end = p; |
1134 looked = 0; | |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1135 state = ssi_start_state; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1136 break; |
14
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1137 } |
16
6ce4755737b4
nginx-0.0.1-2002-09-26-20:50:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
15
diff
changeset
|
1138 |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1139 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1140 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1141 case ssi_precommand_state: |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1142 switch (ch) { |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1143 case ' ': |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1144 case CR: |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1145 case LF: |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1146 case '\t': |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1147 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1148 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1149 default: |
489 | 1150 ctx->command.len = 1; |
497 | 1151 ctx->command.data = ngx_palloc(r->pool, |
609 | 1152 NGX_HTTP_SSI_COMMAND_LEN); |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1153 if (ctx->command.data == NULL) { |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1154 return NGX_ERROR; |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1155 } |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1156 |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1157 ctx->command.data[0] = ch; |
609 | 1158 |
597 | 1159 ctx->key = 0; |
1160 ctx->key = ngx_hash(ctx->key, ch); | |
1161 | |
497 | 1162 ctx->params.nelts = 0; |
629 | 1163 |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1164 state = ssi_command_state; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1165 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1166 } |
16
6ce4755737b4
nginx-0.0.1-2002-09-26-20:50:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
15
diff
changeset
|
1167 |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1168 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1169 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1170 case ssi_command_state: |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1171 switch (ch) { |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1172 case ' ': |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1173 case CR: |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1174 case LF: |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1175 case '\t': |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1176 state = ssi_preparam_state; |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1177 break; |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1178 |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1179 case '-': |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1180 state = ssi_comment_end0_state; |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1181 break; |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1182 |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1183 default: |
497 | 1184 if (ctx->command.len == NGX_HTTP_SSI_COMMAND_LEN) { |
1185 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
609 | 1186 "the \"%V%c...\" SSI command is too long", |
1187 &ctx->command, ch); | |
497 | 1188 |
1189 state = ssi_error_state; | |
1190 break; | |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1191 } |
609 | 1192 |
1193 ctx->command.data[ctx->command.len++] = ch; | |
1194 ctx->key = ngx_hash(ctx->key, ch); | |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1195 } |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1196 |
14
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1197 break; |
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1198 |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1199 case ssi_preparam_state: |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1200 switch (ch) { |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1201 case ' ': |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1202 case CR: |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1203 case LF: |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1204 case '\t': |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1205 break; |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1206 |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1207 case '-': |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1208 state = ssi_comment_end0_state; |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1209 break; |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1210 |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1211 default: |
499 | 1212 ctx->param = ngx_array_push(&ctx->params); |
1213 if (ctx->param == NULL) { | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1214 return NGX_ERROR; |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1215 } |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1216 |
489 | 1217 ctx->param->key.len = 1; |
497 | 1218 ctx->param->key.data = ngx_palloc(r->pool, |
609 | 1219 NGX_HTTP_SSI_PARAM_LEN); |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1220 if (ctx->param->key.data == NULL) { |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1221 return NGX_ERROR; |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1222 } |
497 | 1223 |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1224 ctx->param->key.data[0] = ch; |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1225 |
489 | 1226 ctx->param->value.len = 0; |
609 | 1227 |
1228 if (ctx->value_buf == NULL) { | |
1229 ctx->param->value.data = ngx_palloc(r->pool, | |
1230 ctx->value_len); | |
1231 if (ctx->param->value.data == NULL) { | |
1232 return NGX_ERROR; | |
1233 } | |
1234 | |
1235 } else { | |
1236 ctx->param->value.data = ctx->value_buf; | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1237 } |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1238 |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1239 state = ssi_param_state; |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1240 break; |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1241 } |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1242 |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1243 break; |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1244 |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1245 case ssi_param_state: |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1246 switch (ch) { |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1247 case ' ': |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1248 case CR: |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1249 case LF: |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1250 case '\t': |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1251 state = ssi_preequal_state; |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1252 break; |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1253 |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1254 case '=': |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1255 state = ssi_prevalue_state; |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1256 break; |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1257 |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1258 case '-': |
497 | 1259 state = ssi_error_end0_state; |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1260 |
497 | 1261 ctx->param->key.data[ctx->param->key.len++] = ch; |
1262 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1263 "invalid \"%V\" parameter in \"%V\" SSI command", | |
1264 &ctx->param->key, &ctx->command); | |
1265 break; | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1266 |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1267 default: |
497 | 1268 if (ctx->param->key.len == NGX_HTTP_SSI_PARAM_LEN) { |
1269 state = ssi_error_state; | |
1270 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
609 | 1271 "too long \"%V%c...\" parameter in " |
497 | 1272 "\"%V\" SSI command", |
609 | 1273 &ctx->param->key, ch, &ctx->command); |
497 | 1274 break; |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1275 } |
609 | 1276 |
1277 ctx->param->key.data[ctx->param->key.len++] = ch; | |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1278 } |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1279 |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1280 break; |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1281 |
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1282 case ssi_preequal_state: |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1283 switch (ch) { |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1284 case ' ': |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1285 case CR: |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1286 case LF: |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1287 case '\t': |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1288 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1289 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1290 case '=': |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1291 state = ssi_prevalue_state; |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1292 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1293 |
497 | 1294 default: |
1295 if (ch == '-') { | |
1296 state = ssi_error_end0_state; | |
1297 } else { | |
1298 state = ssi_error_state; | |
1299 } | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1300 |
497 | 1301 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
1302 "unexpected \"%c\" symbol after \"%V\" " | |
1303 "parameter in \"%V\" SSI command", | |
1304 ch, &ctx->param->key, &ctx->command); | |
1305 break; | |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1306 } |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1307 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1308 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1309 |
127
4cbe22f9907f
nginx-0.0.1-2003-08-07-10:07:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
126
diff
changeset
|
1310 case ssi_prevalue_state: |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1311 switch (ch) { |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1312 case ' ': |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1313 case CR: |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1314 case LF: |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1315 case '\t': |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1316 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1317 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1318 case '"': |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1319 state = ssi_double_quoted_value_state; |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1320 break; |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1321 |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1322 case '\'': |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1323 state = ssi_quoted_value_state; |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1324 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1325 |
497 | 1326 default: |
1327 if (ch == '-') { | |
1328 state = ssi_error_end0_state; | |
1329 } else { | |
1330 state = ssi_error_state; | |
1331 } | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1332 |
497 | 1333 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
1334 "unexpected \"%c\" symbol before value of " | |
1335 "\"%V\" parameter in \"%V\" SSI command", | |
1336 ch, &ctx->param->key, &ctx->command); | |
1337 break; | |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1338 } |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1339 |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1340 break; |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1341 |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1342 case ssi_double_quoted_value_state: |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1343 switch (ch) { |
559 | 1344 case '"': |
1345 state = ssi_postparam_state; | |
1346 break; | |
1347 | |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1348 case '\\': |
497 | 1349 ctx->saved_state = ssi_double_quoted_value_state; |
1350 state = ssi_quoted_symbol_state; | |
559 | 1351 |
1352 /* fall through */ | |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1353 |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1354 default: |
497 | 1355 if (ctx->param->value.len == ctx->value_len) { |
1356 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
609 | 1357 "too long \"%V%c...\" value of \"%V\" " |
1358 "parameter in \"%V\" SSI command", | |
1359 &ctx->param->value, ch, &ctx->param->key, | |
497 | 1360 &ctx->command); |
1361 state = ssi_error_state; | |
1362 break; | |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1363 } |
609 | 1364 |
1365 ctx->param->value.data[ctx->param->value.len++] = ch; | |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1366 } |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1367 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1368 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1369 |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1370 case ssi_quoted_value_state: |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1371 switch (ch) { |
559 | 1372 case '\'': |
1373 state = ssi_postparam_state; | |
1374 break; | |
1375 | |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1376 case '\\': |
497 | 1377 ctx->saved_state = ssi_quoted_value_state; |
1378 state = ssi_quoted_symbol_state; | |
559 | 1379 |
1380 /* fall through */ | |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1381 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1382 default: |
497 | 1383 if (ctx->param->value.len == ctx->value_len) { |
1384 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
609 | 1385 "too long \"%V%c...\" value of \"%V\" " |
1386 "parameter in \"%V\" SSI command", | |
1387 &ctx->param->value, ch, &ctx->param->key, | |
497 | 1388 &ctx->command); |
1389 state = ssi_error_state; | |
1390 break; | |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1391 } |
609 | 1392 |
1393 ctx->param->value.data[ctx->param->value.len++] = ch; | |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1394 } |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1395 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1396 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1397 |
497 | 1398 case ssi_quoted_symbol_state: |
559 | 1399 state = ctx->saved_state; |
1400 | |
497 | 1401 ctx->param->value.data[ctx->param->value.len++] = ch; |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1402 |
497 | 1403 break; |
1404 | |
1405 case ssi_postparam_state: | |
609 | 1406 |
651 | 1407 if (ctx->param->value.len + 1 < ctx->value_len / 2) { |
1408 value = ngx_palloc(r->pool, ctx->param->value.len + 1); | |
609 | 1409 if (value == NULL) { |
1410 return NGX_ERROR; | |
1411 } | |
1412 | |
1413 ngx_memcpy(value, ctx->param->value.data, | |
1414 ctx->param->value.len); | |
1415 | |
1416 ctx->value_buf = ctx->param->value.data; | |
1417 ctx->param->value.data = value; | |
1418 | |
1419 } else { | |
1420 ctx->value_buf = NULL; | |
1421 } | |
1422 | |
497 | 1423 switch (ch) { |
1424 case ' ': | |
1425 case CR: | |
1426 case LF: | |
1427 case '\t': | |
1428 state = ssi_preparam_state; | |
1429 break; | |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1430 |
497 | 1431 case '-': |
1432 state = ssi_comment_end0_state; | |
1433 break; | |
1434 | |
1435 default: | |
1436 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1437 "unexpected \"%c\" symbol after \"%V\" value " | |
1438 "of \"%V\" parameter in \"%V\" SSI command", | |
1439 ch, &ctx->param->value, &ctx->param->key, | |
1440 &ctx->command); | |
1441 state = ssi_error_state; | |
1442 break; | |
1443 } | |
1444 | |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1445 break; |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1446 |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1447 case ssi_comment_end0_state: |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1448 switch (ch) { |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1449 case '-': |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1450 state = ssi_comment_end1_state; |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1451 break; |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1452 |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1453 default: |
497 | 1454 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
1455 "unexpected \"%c\" symbol in \"%V\" SSI command", | |
1456 ch, &ctx->command); | |
1457 state = ssi_error_state; | |
1458 break; | |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1459 } |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1460 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1461 break; |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1462 |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1463 case ssi_comment_end1_state: |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1464 switch (ch) { |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1465 case '>': |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1466 ctx->state = ssi_start_state; |
497 | 1467 ctx->pos = p + 1; |
1468 ctx->looked = looked; | |
1469 ctx->copy_end = copy_end; | |
1470 | |
1471 if (ctx->copy_start == NULL && copy_end) { | |
1472 ctx->copy_start = ctx->buf->pos; | |
1473 } | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1474 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1475 return NGX_OK; |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1476 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1477 default: |
497 | 1478 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
1479 "unexpected \"%c\" symbol in \"%V\" SSI command", | |
1480 ch, &ctx->command); | |
1481 state = ssi_error_state; | |
1482 break; | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1483 } |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1484 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1485 break; |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1486 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1487 case ssi_error_state: |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1488 switch (ch) { |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1489 case '-': |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1490 state = ssi_error_end0_state; |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1491 break; |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1492 |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1493 default: |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1494 break; |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1495 } |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1496 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1497 break; |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1498 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1499 case ssi_error_end0_state: |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1500 switch (ch) { |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1501 case '-': |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1502 state = ssi_error_end1_state; |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1503 break; |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1504 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1505 default: |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1506 state = ssi_error_state; |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1507 break; |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1508 } |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1509 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1510 break; |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1511 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1512 case ssi_error_end1_state: |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1513 switch (ch) { |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1514 case '>': |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1515 ctx->state = ssi_start_state; |
497 | 1516 ctx->pos = p + 1; |
1517 ctx->looked = looked; | |
1518 ctx->copy_end = copy_end; | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1519 |
497 | 1520 if (ctx->copy_start == NULL && copy_end) { |
1521 ctx->copy_start = ctx->buf->pos; | |
1522 } | |
1523 | |
1524 return NGX_HTTP_SSI_ERROR; | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1525 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
1526 default: |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
1527 state = ssi_error_state; |
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
1528 break; |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1529 } |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1530 |
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1531 break; |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1532 } |
16
6ce4755737b4
nginx-0.0.1-2002-09-26-20:50:29 import
Igor Sysoev <igor@sysoev.ru>
parents:
15
diff
changeset
|
1533 } |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1534 |
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1535 ctx->state = state; |
128
1947c683490f
nginx-0.0.1-2003-08-08-19:13:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
127
diff
changeset
|
1536 ctx->pos = p; |
497 | 1537 ctx->looked = looked; |
126
fcc79370b9a8
nginx-0.0.1-2003-08-06-18:43:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
125
diff
changeset
|
1538 |
497 | 1539 ctx->copy_end = (state == ssi_start_state) ? p : copy_end; |
1540 | |
1541 if (ctx->copy_start == NULL && ctx->copy_end) { | |
1542 ctx->copy_start = ctx->buf->pos; | |
1543 } | |
1544 | |
1545 return NGX_AGAIN; | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1546 } |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1547 |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
1548 |
553 | 1549 static ngx_str_t * |
611 | 1550 ngx_http_ssi_get_variable(ngx_http_request_t *r, ngx_str_t *name, |
1551 ngx_uint_t key) | |
553 | 1552 { |
1553 ngx_uint_t i; | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1554 ngx_list_part_t *part; |
553 | 1555 ngx_http_ssi_var_t *var; |
1556 ngx_http_ssi_ctx_t *ctx; | |
1557 | |
1558 ctx = ngx_http_get_module_ctx(r->main, ngx_http_ssi_filter_module); | |
1559 | |
667 | 1560 if (ctx->variables == NULL) { |
1561 return NULL; | |
1562 } | |
1563 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1564 part = &ctx->variables->part; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1565 var = part->elts; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1566 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1567 for (i = 0; /* void */ ; i++) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1568 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1569 if (i >= part->nelts) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1570 if (part->next == NULL) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1571 break; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1572 } |
787
b310630d129e
style fix: remove trailing spaces
Igor Sysoev <igor@sysoev.ru>
parents:
784
diff
changeset
|
1573 |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1574 part = part->next; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1575 var = part->elts; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1576 i = 0; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1577 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1578 |
553 | 1579 if (name->len != var[i].name.len) { |
1580 continue; | |
1581 } | |
1582 | |
611 | 1583 if (key != var[i].key) { |
1584 continue; | |
1585 } | |
1586 | |
1587 if (ngx_strncmp(name->data, var[i].name.data, name->len) == 0) { | |
553 | 1588 return &var[i].value; |
1589 } | |
1590 } | |
1591 | |
1592 return NULL; | |
1593 } | |
1594 | |
1595 | |
1596 static ngx_int_t | |
1597 ngx_http_ssi_evaluate_string(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, | |
1598 ngx_str_t *text, ngx_uint_t flags) | |
1599 { | |
573 | 1600 u_char ch, *p, **value, *data, *part_data; |
1601 size_t *size, len, prefix, part_len; | |
1602 ngx_str_t var, *val; | |
611 | 1603 ngx_int_t key; |
651 | 1604 ngx_uint_t i, j, n, bracket, quoted; |
553 | 1605 ngx_array_t lengths, values; |
1606 ngx_http_variable_value_t *vv; | |
1607 | |
1608 n = ngx_http_script_variables_count(text); | |
1609 | |
1610 if (n == 0) { | |
1611 | |
657 | 1612 data = text->data; |
1613 p = data; | |
1614 | |
1615 if ((flags & NGX_HTTP_SSI_ADD_PREFIX) && text->data[0] != '/') { | |
1616 | |
553 | 1617 for (prefix = r->uri.len; prefix; prefix--) { |
1618 if (r->uri.data[prefix - 1] == '/') { | |
1619 break; | |
1620 } | |
1621 } | |
1622 | |
1623 if (prefix) { | |
1624 len = prefix + text->len; | |
1625 | |
1626 data = ngx_palloc(r->pool, len); | |
1627 if (data == NULL) { | |
1628 return NGX_ERROR; | |
1629 } | |
1630 | |
573 | 1631 p = ngx_copy(data, r->uri.data, prefix); |
553 | 1632 } |
1633 } | |
1634 | |
657 | 1635 quoted = 0; |
1636 | |
1637 for (i = 0 ; i < text->len; i++) { | |
1638 ch = text->data[i]; | |
1639 | |
1640 if (!quoted) { | |
1641 | |
1642 if (ch == '\\') { | |
1643 quoted = 1; | |
1644 continue; | |
1645 } | |
1646 | |
1647 } else { | |
1648 quoted = 0; | |
1649 | |
1650 if (ch != '\\' && ch != '\'' && ch != '"' && ch != '$') { | |
1651 *p++ = '\\'; | |
1652 } | |
1653 } | |
1654 | |
1655 *p++ = ch; | |
1656 } | |
1657 | |
1658 text->len = p - data; | |
1659 text->data = data; | |
1660 | |
553 | 1661 return NGX_OK; |
1662 } | |
1663 | |
1664 if (ngx_array_init(&lengths, r->pool, 8, sizeof(size_t *)) != NGX_OK) { | |
1665 return NGX_ERROR; | |
1666 } | |
1667 | |
1668 if (ngx_array_init(&values, r->pool, 8, sizeof(u_char *)) != NGX_OK) { | |
1669 return NGX_ERROR; | |
1670 } | |
1671 | |
1672 len = 0; | |
1673 i = 0; | |
1674 | |
1675 while (i < text->len) { | |
1676 | |
1677 if (text->data[i] == '$') { | |
1678 | |
1679 var.len = 0; | |
1680 | |
1681 if (++i == text->len) { | |
1682 goto invalid_variable; | |
1683 } | |
1684 | |
1685 if (text->data[i] == '{') { | |
1686 bracket = 1; | |
1687 | |
1688 if (++i == text->len) { | |
1689 goto invalid_variable; | |
1690 } | |
1691 | |
1692 var.data = &text->data[i]; | |
1693 | |
1694 } else { | |
1695 bracket = 0; | |
1696 var.data = &text->data[i]; | |
1697 } | |
1698 | |
1699 for ( /* void */ ; i < text->len; i++, var.len++) { | |
1700 ch = text->data[i]; | |
1701 | |
1702 if (ch == '}' && bracket) { | |
1703 i++; | |
1704 bracket = 0; | |
1705 break; | |
1706 } | |
1707 | |
1708 if ((ch >= 'A' && ch <= 'Z') | |
1709 || (ch >= 'a' && ch <= 'z') | |
1710 || (ch >= '0' && ch <= '9') | |
1711 || ch == '_') | |
1712 { | |
1713 continue; | |
1714 } | |
1715 | |
1716 break; | |
1717 } | |
1718 | |
1719 if (bracket) { | |
1720 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1721 "the closing bracket in \"%V\" " | |
1722 "variable is missing", &var); | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1723 return NGX_HTTP_SSI_ERROR; |
553 | 1724 } |
1725 | |
577 | 1726 if (var.len == 0) { |
553 | 1727 goto invalid_variable; |
1728 } | |
1729 | |
611 | 1730 key = 0; |
1731 | |
553 | 1732 for (j = 0; j < var.len; j++) { |
1733 var.data[j] = ngx_tolower(var.data[j]); | |
611 | 1734 key = ngx_hash(key, var.data[j]); |
553 | 1735 } |
1736 | |
611 | 1737 val = ngx_http_ssi_get_variable(r, &var, key); |
553 | 1738 |
1739 if (val == NULL) { | |
635 | 1740 vv = ngx_http_get_variable(r, &var, key, |
1741 flags & NGX_HTTP_SSI_EXPR_TEST); | |
553 | 1742 if (vv == NULL) { |
1743 return NGX_ERROR; | |
1744 } | |
1745 | |
573 | 1746 if (vv->not_found) { |
553 | 1747 continue; |
1748 } | |
1749 | |
573 | 1750 part_data = vv->data; |
1751 part_len = vv->len; | |
553 | 1752 |
1753 } else { | |
573 | 1754 part_data = val->data; |
1755 part_len = val->len; | |
553 | 1756 } |
1757 | |
1758 } else { | |
573 | 1759 part_data = &text->data[i]; |
651 | 1760 quoted = 0; |
573 | 1761 |
1762 for (p = part_data; i < text->len; i++) { | |
559 | 1763 ch = text->data[i]; |
1764 | |
651 | 1765 if (!quoted) { |
1766 | |
1767 if (ch == '\\') { | |
1768 quoted = 1; | |
1769 continue; | |
1770 } | |
1771 | |
1772 if (ch == '$') { | |
559 | 1773 break; |
1774 } | |
1775 | |
651 | 1776 } else { |
1777 quoted = 0; | |
1778 | |
1779 if (ch != '\\' && ch != '\'' && ch != '"' && ch != '$') { | |
1780 *p++ = '\\'; | |
1781 } | |
559 | 1782 } |
1783 | |
1784 *p++ = ch; | |
553 | 1785 } |
559 | 1786 |
573 | 1787 part_len = p - part_data; |
553 | 1788 } |
1789 | |
573 | 1790 len += part_len; |
553 | 1791 |
1792 size = ngx_array_push(&lengths); | |
1793 if (size == NULL) { | |
1794 return NGX_ERROR; | |
1795 } | |
1796 | |
573 | 1797 *size = part_len; |
553 | 1798 |
1799 value = ngx_array_push(&values); | |
1800 if (value == NULL) { | |
1801 return NGX_ERROR; | |
1802 } | |
1803 | |
573 | 1804 *value = part_data; |
553 | 1805 } |
1806 | |
1807 prefix = 0; | |
1808 | |
1809 size = lengths.elts; | |
1810 value = values.elts; | |
1811 | |
1812 if (flags & NGX_HTTP_SSI_ADD_PREFIX) { | |
1813 for (i = 0; i < values.nelts; i++) { | |
1814 if (size[i] != 0) { | |
1815 if (*value[i] != '/') { | |
1816 for (prefix = r->uri.len; prefix; prefix--) { | |
1817 if (r->uri.data[prefix - 1] == '/') { | |
1818 len += prefix; | |
1819 break; | |
1820 } | |
1821 } | |
1822 } | |
1823 | |
1824 break; | |
1825 } | |
1826 } | |
1827 } | |
1828 | |
629 | 1829 p = ngx_palloc(r->pool, len + ((flags & NGX_HTTP_SSI_ADD_ZERO) ? 1 : 0)); |
553 | 1830 if (p == NULL) { |
1831 return NGX_ERROR; | |
1832 } | |
1833 | |
1834 text->len = len; | |
1835 text->data = p; | |
1836 | |
573 | 1837 p = ngx_copy(p, r->uri.data, prefix); |
553 | 1838 |
1839 for (i = 0; i < values.nelts; i++) { | |
573 | 1840 p = ngx_copy(p, value[i], size[i]); |
553 | 1841 } |
1842 | |
1843 return NGX_OK; | |
1844 | |
1845 invalid_variable: | |
1846 | |
1847 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1848 "invalid variable name in \"%V\"", text); | |
1849 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1850 return NGX_HTTP_SSI_ERROR; |
553 | 1851 } |
1852 | |
1853 | |
1854 static ngx_int_t | |
1855 ngx_http_ssi_include(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, | |
1856 ngx_str_t **params) | |
1857 { | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1858 ngx_int_t rc, key; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1859 ngx_str_t *uri, *file, *wait, *set, *stub, args; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1860 ngx_buf_t *b; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1861 ngx_uint_t flags, i; |
784
5a164305b960
fix building by Debian gcc-4.1.2 amd64
Igor Sysoev <igor@sysoev.ru>
parents:
777
diff
changeset
|
1862 ngx_chain_t *cl, *tl, **ll, *out; |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1863 ngx_http_request_t *sr; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1864 ngx_http_ssi_var_t *var; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1865 ngx_http_ssi_ctx_t *mctx; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1866 ngx_http_ssi_block_t *bl; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1867 ngx_http_post_subrequest_t *psr; |
553 | 1868 |
1869 uri = params[NGX_HTTP_SSI_INCLUDE_VIRTUAL]; | |
1870 file = params[NGX_HTTP_SSI_INCLUDE_FILE]; | |
645 | 1871 wait = params[NGX_HTTP_SSI_INCLUDE_WAIT]; |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1872 set = params[NGX_HTTP_SSI_INCLUDE_SET]; |
667 | 1873 stub = params[NGX_HTTP_SSI_INCLUDE_STUB]; |
553 | 1874 |
1875 if (uri && file) { | |
1876 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1877 "inlcusion may be either virtual=\"%V\" or file=\"%V\"", | |
1878 uri, file); | |
1879 return NGX_HTTP_SSI_ERROR; | |
1880 } | |
1881 | |
1882 if (uri == NULL && file == NULL) { | |
1883 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1884 "no parameter in \"include\" SSI command"); | |
1885 return NGX_HTTP_SSI_ERROR; | |
1886 } | |
1887 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1888 if (set && stub) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1889 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1890 "\"set\" and \"stub\" may not be used together " |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1891 "in \"include\" SSI command"); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1892 return NGX_HTTP_SSI_ERROR; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1893 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1894 |
645 | 1895 if (wait) { |
1896 if (uri == NULL) { | |
1897 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
667 | 1898 "\"wait\" may not be used with file=\"%V\"", file); |
645 | 1899 return NGX_HTTP_SSI_ERROR; |
1900 } | |
1901 | |
1107
db7c468c447d
ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents:
1025
diff
changeset
|
1902 if (wait->len == 2 |
db7c468c447d
ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents:
1025
diff
changeset
|
1903 && ngx_strncasecmp(wait->data, (u_char *) "no", 2) == 0) |
db7c468c447d
ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents:
1025
diff
changeset
|
1904 { |
645 | 1905 wait = NULL; |
1906 | |
1107
db7c468c447d
ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents:
1025
diff
changeset
|
1907 } else if (wait->len != 3 |
db7c468c447d
ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents:
1025
diff
changeset
|
1908 || ngx_strncasecmp(wait->data, (u_char *) "yes", 3) != 0) |
645 | 1909 { |
1910 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1911 "invalid value \"%V\" in the \"wait\" parameter", | |
667 | 1912 wait); |
645 | 1913 return NGX_HTTP_SSI_ERROR; |
1914 } | |
1915 } | |
1916 | |
553 | 1917 if (uri == NULL) { |
1918 uri = file; | |
1919 } | |
1920 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1921 rc = ngx_http_ssi_evaluate_string(r, ctx, uri, NGX_HTTP_SSI_ADD_PREFIX); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1922 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1923 if (rc != NGX_OK) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1924 return rc; |
553 | 1925 } |
1926 | |
1927 args.len = 0; | |
1928 args.data = NULL; | |
573 | 1929 flags = 0; |
1930 | |
1931 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1932 "ssi include: \"%V\"", uri); | |
1933 | |
1934 if (ngx_http_parse_unsafe_uri(r, uri, &args, &flags) != NGX_OK) { | |
1935 return NGX_HTTP_SSI_ERROR; | |
553 | 1936 } |
1937 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1938 psr = NULL; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1939 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1940 mctx = ngx_http_get_module_ctx(r->main, ngx_http_ssi_filter_module); |
667 | 1941 |
1942 if (stub) { | |
1943 if (mctx->blocks) { | |
1944 bl = mctx->blocks->elts; | |
1945 for (i = 0; i < mctx->blocks->nelts; i++) { | |
1946 if (stub->len == bl[i].name.len | |
1947 && ngx_strncmp(stub->data, bl[i].name.data, stub->len) == 0) | |
1948 { | |
1949 goto found; | |
1950 } | |
1951 } | |
1952 } | |
1953 | |
1954 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1955 "\"stub\"=\"%V\" for \"include\" not found", stub); | |
1956 return NGX_HTTP_SSI_ERROR; | |
1957 | |
1958 found: | |
1959 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1960 psr = ngx_palloc(r->pool, sizeof(ngx_http_post_subrequest_t)); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1961 if (psr == NULL) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1962 return NGX_ERROR; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1963 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1964 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1965 psr->handler = ngx_http_ssi_stub_output; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
1966 |
667 | 1967 if (bl[i].count++) { |
1968 | |
784
5a164305b960
fix building by Debian gcc-4.1.2 amd64
Igor Sysoev <igor@sysoev.ru>
parents:
777
diff
changeset
|
1969 ll = &out; |
667 | 1970 |
1971 for (tl = bl[i].bufs; tl; tl = tl->next) { | |
1972 | |
1973 if (ctx->free) { | |
1974 cl = ctx->free; | |
1975 ctx->free = ctx->free->next; | |
1976 b = cl->buf; | |
1977 | |
1978 } else { | |
1979 b = ngx_alloc_buf(r->pool); | |
1980 if (b == NULL) { | |
1981 return NGX_ERROR; | |
1982 } | |
1983 | |
1984 cl = ngx_alloc_chain_link(r->pool); | |
1985 if (cl == NULL) { | |
1986 return NGX_ERROR; | |
1987 } | |
1988 | |
1989 cl->buf = b; | |
1990 } | |
1991 | |
1992 ngx_memcpy(b, tl->buf, sizeof(ngx_buf_t)); | |
1993 | |
1994 b->pos = b->start; | |
1995 | |
1996 *ll = cl; | |
1997 cl->next = NULL; | |
1998 ll = &cl->next; | |
1999 } | |
2000 | |
784
5a164305b960
fix building by Debian gcc-4.1.2 amd64
Igor Sysoev <igor@sysoev.ru>
parents:
777
diff
changeset
|
2001 psr->data = out; |
5a164305b960
fix building by Debian gcc-4.1.2 amd64
Igor Sysoev <igor@sysoev.ru>
parents:
777
diff
changeset
|
2002 |
667 | 2003 } else { |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2004 psr->data = bl[i].bufs; |
667 | 2005 } |
2006 } | |
2007 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2008 if (set) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2009 key = 0; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2010 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2011 for (i = 0; i < set->len; i++) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2012 set->data[i] = ngx_tolower(set->data[i]); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2013 key = ngx_hash(key, set->data[i]); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2014 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2015 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2016 psr = ngx_palloc(r->pool, sizeof(ngx_http_post_subrequest_t)); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2017 if (psr == NULL) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2018 return NGX_ERROR; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2019 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2020 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2021 psr->handler = ngx_http_ssi_set_variable; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2022 psr->data = ngx_http_ssi_get_variable(r, set, key); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2023 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2024 if (psr->data == NULL) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2025 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2026 if (mctx->variables == NULL) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2027 mctx->variables = ngx_list_create(r->pool, 4, |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2028 sizeof(ngx_http_ssi_var_t)); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2029 if (mctx->variables == NULL) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2030 return NGX_ERROR; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2031 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2032 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2033 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2034 var = ngx_list_push(mctx->variables); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2035 if (var == NULL) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2036 return NGX_ERROR; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2037 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2038 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2039 var->name = *set; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2040 var->key = key; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2041 var->value = ngx_http_ssi_null_string; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2042 psr->data = &var->value; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2043 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2044 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2045 flags |= NGX_HTTP_SUBREQUEST_IN_MEMORY; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2046 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2047 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2048 rc = ngx_http_subrequest(r, uri, &args, &sr, psr, flags); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2049 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2050 if (rc == NGX_DONE) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2051 return NGX_DONE; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2052 } |
645 | 2053 |
2054 if (rc == NGX_ERROR) { | |
553 | 2055 return NGX_HTTP_SSI_ERROR; |
2056 } | |
2057 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2058 if (wait == NULL && set == NULL) { |
645 | 2059 return NGX_OK; |
2060 } | |
2061 | |
2062 if (rc == NGX_AGAIN) { | |
758
86bb73dc8d40
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
710
diff
changeset
|
2063 if (ctx->wait == NULL) { |
86bb73dc8d40
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
710
diff
changeset
|
2064 ctx->wait = sr; |
86bb73dc8d40
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
710
diff
changeset
|
2065 |
86bb73dc8d40
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
710
diff
changeset
|
2066 } else { |
86bb73dc8d40
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
710
diff
changeset
|
2067 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
86bb73dc8d40
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
710
diff
changeset
|
2068 "only one subrequest may be waited at the same time"); |
86bb73dc8d40
fix <!--#include virtual=... wait="yes" -->
Igor Sysoev <igor@sysoev.ru>
parents:
710
diff
changeset
|
2069 } |
645 | 2070 } |
2071 | |
2072 return rc; | |
553 | 2073 } |
2074 | |
2075 | |
497 | 2076 static ngx_int_t |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2077 ngx_http_ssi_stub_output(ngx_http_request_t *r, void *data, ngx_int_t rc) |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2078 { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2079 ngx_chain_t *out; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2080 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2081 if (rc == NGX_ERROR || r->connection->error || r->request_output) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2082 return rc; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2083 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2084 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2085 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2086 "ssi stub output: \"%V?%V\"", &r->uri, &r->args); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2087 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2088 out = data; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2089 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2090 if (!r->header_sent) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2091 if (ngx_http_set_content_type(r) == NGX_ERROR) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2092 return NGX_ERROR; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2093 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2094 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2095 if (ngx_http_send_header(r) == NGX_ERROR) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2096 return NGX_ERROR; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2097 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2098 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2099 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2100 return ngx_http_output_filter(r, out); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2101 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2102 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2103 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2104 static ngx_int_t |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2105 ngx_http_ssi_set_variable(ngx_http_request_t *r, void *data, ngx_int_t rc) |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2106 { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2107 ngx_str_t *value = data; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2108 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2109 if (r->upstream) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2110 value->len = r->upstream->buffer.last - r->upstream->buffer.pos; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2111 value->data = r->upstream->buffer.pos; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2112 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2113 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2114 return rc; |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2115 } |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2116 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2117 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2118 static ngx_int_t |
497 | 2119 ngx_http_ssi_echo(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, |
2120 ngx_str_t **params) | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
2121 { |
611 | 2122 ngx_int_t key; |
501 | 2123 ngx_uint_t i; |
499 | 2124 ngx_buf_t *b; |
573 | 2125 ngx_str_t *var, *value, text; |
499 | 2126 ngx_chain_t *cl; |
501 | 2127 ngx_http_variable_value_t *vv; |
497 | 2128 |
2129 var = params[NGX_HTTP_SSI_ECHO_VAR]; | |
2130 | |
643 | 2131 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
2132 "ssi echo \"%V\"", var); | |
2133 | |
611 | 2134 key = 0; |
2135 | |
2136 for (i = 0; i < var->len; i++) { | |
2137 var->data[i] = ngx_tolower(var->data[i]); | |
2138 key = ngx_hash(key, var->data[i]); | |
2139 } | |
2140 | |
2141 value = ngx_http_ssi_get_variable(r, var, key); | |
553 | 2142 |
2143 if (value == NULL) { | |
635 | 2144 vv = ngx_http_get_variable(r, var, key, 1); |
553 | 2145 |
2146 if (vv == NULL) { | |
2147 return NGX_HTTP_SSI_ERROR; | |
2148 } | |
2149 | |
573 | 2150 if (!vv->not_found) { |
2151 text.data = vv->data; | |
2152 text.len = vv->len; | |
2153 value = &text; | |
553 | 2154 } |
501 | 2155 } |
497 | 2156 |
553 | 2157 if (value == NULL) { |
499 | 2158 value = params[NGX_HTTP_SSI_ECHO_DEFAULT]; |
2159 | |
2160 if (value == NULL) { | |
2161 value = &ngx_http_ssi_none; | |
2162 | |
2163 } else if (value->len == 0) { | |
2164 return NGX_OK; | |
2165 } | |
2166 | |
2167 } else { | |
2168 if (value->len == 0) { | |
2169 return NGX_OK; | |
2170 } | |
2171 } | |
2172 | |
2173 b = ngx_calloc_buf(r->pool); | |
2174 if (b == NULL) { | |
2175 return NGX_HTTP_SSI_ERROR; | |
2176 } | |
2177 | |
2178 cl = ngx_alloc_chain_link(r->pool); | |
2179 if (cl == NULL) { | |
497 | 2180 return NGX_HTTP_SSI_ERROR; |
2181 } | |
2182 | |
2183 b->memory = 1; | |
2184 b->pos = value->data; | |
2185 b->last = value->data + value->len; | |
2186 | |
2187 cl->buf = b; | |
2188 cl->next = NULL; | |
2189 *ctx->last_out = cl; | |
2190 ctx->last_out = &cl->next; | |
2191 | |
242
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
2192 return NGX_OK; |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
2193 } |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
2194 |
5d4f49dc8de5
nginx-0.0.1-2004-01-28-18:22:37 import
Igor Sysoev <igor@sysoev.ru>
parents:
241
diff
changeset
|
2195 |
509 | 2196 static ngx_int_t |
2197 ngx_http_ssi_config(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, | |
2198 ngx_str_t **params) | |
2199 { | |
2200 ngx_str_t *value; | |
2201 | |
2202 value = params[NGX_HTTP_SSI_CONFIG_TIMEFMT]; | |
2203 | |
2204 if (value) { | |
589 | 2205 ctx->timefmt.len = value->len; |
2206 ctx->timefmt.data = ngx_palloc(r->pool, value->len + 1); | |
2207 if (ctx->timefmt.data == NULL) { | |
2208 return NGX_HTTP_SSI_ERROR; | |
2209 } | |
2210 | |
2211 ngx_cpystrn(ctx->timefmt.data, value->data, value->len + 1); | |
509 | 2212 } |
2213 | |
547 | 2214 value = params[NGX_HTTP_SSI_CONFIG_ERRMSG]; |
2215 | |
2216 if (value) { | |
2217 ctx->errmsg = *value; | |
2218 } | |
2219 | |
509 | 2220 return NGX_OK; |
2221 } | |
2222 | |
2223 | |
2224 static ngx_int_t | |
553 | 2225 ngx_http_ssi_set(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, |
509 | 2226 ngx_str_t **params) |
2227 { | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2228 ngx_int_t key, rc; |
611 | 2229 ngx_uint_t i; |
553 | 2230 ngx_str_t *name, *value, *vv; |
2231 ngx_http_ssi_var_t *var; | |
2232 ngx_http_ssi_ctx_t *mctx; | |
2233 | |
2234 mctx = ngx_http_get_module_ctx(r->main, ngx_http_ssi_filter_module); | |
2235 | |
667 | 2236 if (mctx->variables == NULL) { |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2237 mctx->variables = ngx_list_create(r->pool, 4, |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2238 sizeof(ngx_http_ssi_var_t)); |
667 | 2239 if (mctx->variables == NULL) { |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2240 return NGX_ERROR; |
509 | 2241 } |
2242 } | |
2243 | |
553 | 2244 name = params[NGX_HTTP_SSI_SET_VAR]; |
2245 value = params[NGX_HTTP_SSI_SET_VALUE]; | |
2246 | |
643 | 2247 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
2248 "ssi set \"%V\" \"%V\"", name, value); | |
2249 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2250 rc = ngx_http_ssi_evaluate_string(r, ctx, value, 0); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2251 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2252 if (rc != NGX_OK) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2253 return rc; |
509 | 2254 } |
2255 | |
611 | 2256 key = 0; |
2257 | |
2258 for (i = 0; i < name->len; i++) { | |
2259 name->data[i] = ngx_tolower(name->data[i]); | |
2260 key = ngx_hash(key, name->data[i]); | |
2261 } | |
2262 | |
2263 vv = ngx_http_ssi_get_variable(r, name, key); | |
553 | 2264 |
2265 if (vv) { | |
2266 *vv = *value; | |
2267 return NGX_OK; | |
2268 } | |
2269 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2270 var = ngx_list_push(mctx->variables); |
553 | 2271 if (var == NULL) { |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2272 return NGX_ERROR; |
553 | 2273 } |
2274 | |
2275 var->name = *name; | |
611 | 2276 var->key = key; |
553 | 2277 var->value = *value; |
2278 | |
2279 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
2280 "set: \"%V\"=\"%V\"", name, value); | |
2281 | |
509 | 2282 return NGX_OK; |
2283 } | |
2284 | |
2285 | |
2286 static ngx_int_t | |
2287 ngx_http_ssi_if(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, | |
2288 ngx_str_t **params) | |
2289 { | |
553 | 2290 u_char *p, *last; |
2291 ngx_str_t *expr, left, right; | |
2292 ngx_int_t rc; | |
629 | 2293 ngx_uint_t negative, noregex, flags; |
551 | 2294 #if (NGX_PCRE) |
553 | 2295 ngx_str_t err; |
2296 ngx_regex_t *regex; | |
2297 u_char errstr[NGX_MAX_CONF_ERRSTR]; | |
551 | 2298 #endif |
509 | 2299 |
629 | 2300 if (ctx->command.len == 2) { |
2301 if (ctx->conditional) { | |
2302 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
2303 "the \"if\" command inside the \"if\" command"); | |
2304 return NGX_HTTP_SSI_ERROR; | |
2305 } | |
2306 } | |
2307 | |
2308 if (ctx->output_chosen) { | |
2309 ctx->output = 0; | |
2310 return NGX_OK; | |
2311 } | |
2312 | |
509 | 2313 expr = params[NGX_HTTP_SSI_IF_EXPR]; |
2314 | |
643 | 2315 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
2316 "ssi if expr=\"%V\"", expr); | |
2317 | |
553 | 2318 left.data = expr->data; |
551 | 2319 last = expr->data + expr->len; |
2320 | |
553 | 2321 for (p = left.data; p < last; p++) { |
551 | 2322 if (*p >= 'A' && *p <= 'Z') { |
2323 *p |= 0x20; | |
2324 continue; | |
2325 } | |
509 | 2326 |
553 | 2327 if ((*p >= 'a' && *p <= 'z') |
2328 || (*p >= '0' && *p <= '9') | |
573 | 2329 || *p == '$' || *p == '{' || *p == '}' || *p == '_' |
2330 || *p == '"' || *p == '\'') | |
553 | 2331 { |
551 | 2332 continue; |
2333 } | |
2334 | |
2335 break; | |
2336 } | |
2337 | |
553 | 2338 left.len = p - left.data; |
551 | 2339 |
2340 while (p < last && *p == ' ') { | |
2341 p++; | |
509 | 2342 } |
2343 | |
635 | 2344 flags = (p == last) ? NGX_HTTP_SSI_EXPR_TEST : 0; |
2345 | |
553 | 2346 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
2347 "left: \"%V\"", &left); | |
2348 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2349 rc = ngx_http_ssi_evaluate_string(r, ctx, &left, flags); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2350 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2351 if (rc != NGX_OK) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2352 return rc; |
509 | 2353 } |
2354 | |
553 | 2355 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
2356 "evaluted left: \"%V\"", &left); | |
2357 | |
551 | 2358 if (p == last) { |
553 | 2359 if (left.len) { |
551 | 2360 ctx->output = 1; |
629 | 2361 ctx->output_chosen = 1; |
551 | 2362 |
2363 } else { | |
2364 ctx->output = 0; | |
2365 } | |
2366 | |
629 | 2367 ctx->conditional = NGX_HTTP_SSI_COND_IF; |
2368 | |
551 | 2369 return NGX_OK; |
2370 } | |
2371 | |
2372 if (p < last && *p == '=') { | |
2373 negative = 0; | |
2374 p++; | |
2375 | |
2376 } else if (p + 1 < last && *p == '!' && *(p + 1) == '=') { | |
2377 negative = 1; | |
2378 p += 2; | |
2379 | |
2380 } else { | |
2381 goto invalid_expression; | |
2382 } | |
2383 | |
2384 while (p < last && *p == ' ') { | |
2385 p++; | |
2386 } | |
2387 | |
1190
99c56c0f514e
fix segfault or parsing error in '<!--# if expr="$var = /" -->'
Igor Sysoev <igor@sysoev.ru>
parents:
1169
diff
changeset
|
2388 if (p < last - 1 && *p == '/') { |
551 | 2389 if (*(last - 1) != '/') { |
2390 goto invalid_expression; | |
2391 } | |
2392 | |
2393 noregex = 0; | |
629 | 2394 flags = NGX_HTTP_SSI_ADD_ZERO; |
551 | 2395 last--; |
1025 | 2396 p++; |
551 | 2397 |
2398 } else { | |
2399 noregex = 1; | |
629 | 2400 flags = 0; |
2401 | |
2402 if (p < last - 1 && p[0] == '\\' && p[1] == '/') { | |
651 | 2403 p++; |
629 | 2404 } |
551 | 2405 } |
2406 | |
2407 right.len = last - p; | |
2408 right.data = p; | |
2409 | |
553 | 2410 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
2411 "right: \"%V\"", &right); | |
2412 | |
777
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2413 rc = ngx_http_ssi_evaluate_string(r, ctx, &right, flags); |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2414 |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2415 if (rc != NGX_OK) { |
4ab852b691f5
<!--#include virtual=... set=... -->
Igor Sysoev <igor@sysoev.ru>
parents:
767
diff
changeset
|
2416 return rc; |
551 | 2417 } |
2418 | |
553 | 2419 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
2420 "evaluted right: \"%V\"", &right); | |
551 | 2421 |
2422 if (noregex) { | |
2423 if (left.len != right.len) { | |
2424 rc = -1; | |
2425 | |
2426 } else { | |
2427 rc = ngx_strncmp(left.data, right.data, right.len); | |
2428 } | |
2429 | |
2430 } else { | |
2431 #if (NGX_PCRE) | |
2432 err.len = NGX_MAX_CONF_ERRSTR; | |
2433 err.data = errstr; | |
2434 | |
2435 right.data[right.len] = '\0'; | |
2436 | |
2437 regex = ngx_regex_compile(&right, 0, r->pool, &err); | |
2438 | |
2439 if (regex == NULL) { | |
2440 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "%s", err.data); | |
2441 return NGX_HTTP_SSI_ERROR; | |
2442 } | |
2443 | |
2444 rc = ngx_regex_exec(regex, &left, NULL, 0); | |
2445 | |
2446 if (rc != NGX_REGEX_NO_MATCHED && rc < 0) { | |
2447 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, | |
2448 ngx_regex_exec_n " failed: %d on \"%V\" using \"%V\"", | |
2449 rc, &left, &right); | |
2450 return NGX_HTTP_SSI_ERROR; | |
2451 } | |
2452 #else | |
2453 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, | |
2454 "the using of the regex \"%V\" in SSI " | |
2455 "requires PCRE library", &right); | |
2456 | |
2457 return NGX_HTTP_SSI_ERROR; | |
2458 #endif | |
2459 } | |
2460 | |
2461 if ((rc == 0 && !negative) || (rc != 0 && negative)) { | |
509 | 2462 ctx->output = 1; |
629 | 2463 ctx->output_chosen = 1; |
509 | 2464 |
2465 } else { | |
2466 ctx->output = 0; | |
2467 } | |
2468 | |
629 | 2469 ctx->conditional = NGX_HTTP_SSI_COND_IF; |
2470 | |
509 | 2471 return NGX_OK; |
551 | 2472 |
2473 invalid_expression: | |
2474 | |
2475 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
2476 "invalid expression in \"%V\"", expr); | |
2477 | |
2478 return NGX_HTTP_SSI_ERROR; | |
509 | 2479 } |
2480 | |
2481 | |
2482 static ngx_int_t | |
2483 ngx_http_ssi_else(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, | |
2484 ngx_str_t **params) | |
2485 { | |
643 | 2486 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
2487 "ssi else"); | |
2488 | |
629 | 2489 if (ctx->output_chosen) { |
2490 ctx->output = 0; | |
2491 } else { | |
2492 ctx->output = 1; | |
2493 } | |
2494 | |
2495 ctx->conditional = NGX_HTTP_SSI_COND_ELSE; | |
509 | 2496 |
2497 return NGX_OK; | |
2498 } | |
2499 | |
2500 | |
2501 static ngx_int_t | |
2502 ngx_http_ssi_endif(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, | |
2503 ngx_str_t **params) | |
2504 { | |
643 | 2505 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
2506 "ssi endif"); | |
2507 | |
509 | 2508 ctx->output = 1; |
629 | 2509 ctx->output_chosen = 0; |
2510 ctx->conditional = 0; | |
509 | 2511 |
2512 return NGX_OK; | |
2513 } | |
2514 | |
2515 | |
573 | 2516 static ngx_int_t |
667 | 2517 ngx_http_ssi_block(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, |
2518 ngx_str_t **params) | |
2519 { | |
2520 ngx_http_ssi_ctx_t *mctx; | |
2521 ngx_http_ssi_block_t *bl; | |
2522 | |
2523 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
2524 "ssi block"); | |
2525 | |
2526 mctx = ngx_http_get_module_ctx(r->main, ngx_http_ssi_filter_module); | |
2527 | |
2528 if (mctx->blocks == NULL) { | |
2529 mctx->blocks = ngx_array_create(r->pool, 4, | |
2530 sizeof(ngx_http_ssi_block_t)); | |
2531 if (mctx->blocks == NULL) { | |
2532 return NGX_HTTP_SSI_ERROR; | |
2533 } | |
2534 } | |
2535 | |
2536 bl = ngx_array_push(mctx->blocks); | |
2537 if (bl == NULL) { | |
2538 return NGX_HTTP_SSI_ERROR; | |
2539 } | |
2540 | |
2541 bl->name = *params[NGX_HTTP_SSI_BLOCK_NAME]; | |
2542 bl->bufs = NULL; | |
2543 bl->count = 0; | |
2544 | |
2545 ctx->output = 0; | |
2546 ctx->block = 1; | |
2547 | |
2548 return NGX_OK; | |
2549 } | |
2550 | |
2551 | |
2552 static ngx_int_t | |
2553 ngx_http_ssi_endblock(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, | |
2554 ngx_str_t **params) | |
2555 { | |
2556 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
2557 "ssi endblock"); | |
2558 | |
2559 ctx->output = 1; | |
2560 ctx->block = 0; | |
2561 | |
2562 return NGX_OK; | |
2563 } | |
2564 | |
2565 | |
2566 static ngx_int_t | |
573 | 2567 ngx_http_ssi_date_gmt_local_variable(ngx_http_request_t *r, |
2568 ngx_http_variable_value_t *v, uintptr_t gmt) | |
509 | 2569 { |
573 | 2570 ngx_http_ssi_ctx_t *ctx; |
2571 ngx_time_t *tp; | |
2572 struct tm tm; | |
2573 char buf[NGX_HTTP_SSI_DATE_LEN]; | |
2574 | |
577 | 2575 v->valid = 1; |
573 | 2576 v->no_cachable = 0; |
2577 v->not_found = 0; | |
509 | 2578 |
563 | 2579 tp = ngx_timeofday(); |
2580 | |
509 | 2581 ctx = ngx_http_get_module_ctx(r, ngx_http_ssi_filter_module); |
2582 | |
2583 if (ctx->timefmt.len == sizeof("%s") - 1 | |
2584 && ctx->timefmt.data[0] == '%' && ctx->timefmt.data[1] == 's') | |
2585 { | |
573 | 2586 v->data = ngx_palloc(r->pool, NGX_TIME_T_LEN); |
2587 if (v->data == NULL) { | |
2588 return NGX_ERROR; | |
509 | 2589 } |
2590 | |
573 | 2591 v->len = ngx_sprintf(v->data, "%T", tp->sec + (gmt ? 0 : tp->gmtoff)) |
2592 - v->data; | |
657 | 2593 |
573 | 2594 return NGX_OK; |
509 | 2595 } |
2596 | |
2597 if (gmt) { | |
563 | 2598 ngx_libc_gmtime(tp->sec, &tm); |
509 | 2599 } else { |
563 | 2600 ngx_libc_localtime(tp->sec, &tm); |
509 | 2601 } |
2602 | |
573 | 2603 v->len = strftime(buf, NGX_HTTP_SSI_DATE_LEN, |
2604 (char *) ctx->timefmt.data, &tm); | |
2605 if (v->len == 0) { | |
2606 return NGX_ERROR; | |
509 | 2607 } |
2608 | |
573 | 2609 v->data = ngx_palloc(r->pool, v->len); |
2610 if (v->data == NULL) { | |
2611 return NGX_ERROR; | |
509 | 2612 } |
2613 | |
573 | 2614 ngx_memcpy(v->data, buf, v->len); |
2615 | |
2616 return NGX_OK; | |
509 | 2617 } |
2618 | |
2619 | |
527 | 2620 static char * |
2621 ngx_http_ssi_types(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
2622 { | |
597 | 2623 ngx_http_ssi_loc_conf_t *slcf = conf; |
527 | 2624 |
2625 ngx_str_t *value, *type; | |
2626 ngx_uint_t i; | |
2627 | |
597 | 2628 if (slcf->types == NULL) { |
2629 slcf->types = ngx_array_create(cf->pool, 4, sizeof(ngx_str_t)); | |
2630 if (slcf->types == NULL) { | |
527 | 2631 return NGX_CONF_ERROR; |
2632 } | |
2633 | |
597 | 2634 type = ngx_array_push(slcf->types); |
527 | 2635 if (type == NULL) { |
2636 return NGX_CONF_ERROR; | |
2637 } | |
2638 | |
2639 type->len = sizeof("text/html") - 1; | |
2640 type->data = (u_char *) "text/html"; | |
2641 } | |
2642 | |
2643 value = cf->args->elts; | |
2644 | |
2645 for (i = 1; i < cf->args->nelts; i++) { | |
2646 | |
2647 if (ngx_strcmp(value[i].data, "text/html") == 0) { | |
2648 continue; | |
2649 } | |
2650 | |
597 | 2651 type = ngx_array_push(slcf->types); |
527 | 2652 if (type == NULL) { |
2653 return NGX_CONF_ERROR; | |
2654 } | |
2655 | |
2656 type->len = value[i].len; | |
2657 | |
2658 type->data = ngx_palloc(cf->pool, type->len + 1); | |
2659 if (type->data == NULL) { | |
2660 return NGX_CONF_ERROR; | |
2661 } | |
2662 | |
2663 ngx_cpystrn(type->data, value[i].data, type->len + 1); | |
2664 } | |
2665 | |
2666 return NGX_CONF_OK; | |
2667 } | |
2668 | |
2669 | |
509 | 2670 static ngx_int_t |
597 | 2671 ngx_http_ssi_preconfiguration(ngx_conf_t *cf) |
509 | 2672 { |
597 | 2673 ngx_int_t rc; |
2674 ngx_http_variable_t *var, *v; | |
2675 ngx_http_ssi_command_t *cmd; | |
2676 ngx_http_ssi_main_conf_t *smcf; | |
509 | 2677 |
2678 for (v = ngx_http_ssi_vars; v->name.len; v++) { | |
2679 var = ngx_http_add_variable(cf, &v->name, v->flags); | |
2680 if (var == NULL) { | |
2681 return NGX_ERROR; | |
2682 } | |
2683 | |
637 | 2684 var->get_handler = v->get_handler; |
509 | 2685 var->data = v->data; |
2686 } | |
2687 | |
597 | 2688 smcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_ssi_filter_module); |
2689 | |
2690 for (cmd = ngx_http_ssi_commands; cmd->name.len; cmd++) { | |
2691 rc = ngx_hash_add_key(&smcf->commands, &cmd->name, cmd, | |
2692 NGX_HASH_READONLY_KEY); | |
2693 | |
2694 if (rc == NGX_OK) { | |
2695 continue; | |
2696 } | |
2697 | |
2698 if (rc == NGX_BUSY) { | |
2699 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2700 "conflicting SSI command \"%V\"", &cmd->name); | |
2701 } | |
2702 | |
2703 return NGX_ERROR; | |
2704 } | |
2705 | |
577 | 2706 return NGX_OK; |
509 | 2707 } |
2708 | |
2709 | |
497 | 2710 static void * |
597 | 2711 ngx_http_ssi_create_main_conf(ngx_conf_t *cf) |
2712 { | |
2713 ngx_http_ssi_main_conf_t *smcf; | |
2714 | |
2715 smcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_ssi_main_conf_t)); | |
2716 if (smcf == NULL) { | |
2717 return NGX_CONF_ERROR; | |
2718 } | |
2719 | |
2720 smcf->commands.pool = cf->pool; | |
2721 smcf->commands.temp_pool = cf->temp_pool; | |
2722 | |
2723 if (ngx_hash_keys_array_init(&smcf->commands, NGX_HASH_SMALL) != NGX_OK) { | |
2724 return NGX_CONF_ERROR; | |
2725 } | |
2726 | |
2727 return smcf; | |
2728 } | |
2729 | |
2730 | |
2731 static char * | |
2732 ngx_http_ssi_init_main_conf(ngx_conf_t *cf, void *conf) | |
2733 { | |
2734 ngx_http_ssi_main_conf_t *smcf = conf; | |
2735 | |
2736 ngx_hash_init_t hash; | |
2737 | |
2738 hash.hash = &smcf->hash; | |
2739 hash.key = ngx_hash_key; | |
2740 hash.max_size = 1024; | |
2741 hash.bucket_size = ngx_cacheline_size; | |
2742 hash.name = "ssi_command_hash"; | |
2743 hash.pool = cf->pool; | |
2744 hash.temp_pool = NULL; | |
2745 | |
2746 if (ngx_hash_init(&hash, smcf->commands.keys.elts, | |
2747 smcf->commands.keys.nelts) | |
2748 != NGX_OK) | |
2749 { | |
2750 return NGX_CONF_ERROR; | |
2751 } | |
2752 | |
2753 return NGX_CONF_OK; | |
2754 } | |
2755 | |
2756 | |
2757 static void * | |
1169 | 2758 ngx_http_ssi_create_loc_conf(ngx_conf_t *cf) |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2759 { |
597 | 2760 ngx_http_ssi_loc_conf_t *slcf; |
2761 | |
2762 slcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_ssi_loc_conf_t)); | |
2763 if (slcf == NULL) { | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2764 return NGX_CONF_ERROR; |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2765 } |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2766 |
527 | 2767 /* |
2768 * set by ngx_pcalloc(): | |
2769 * | |
2770 * conf->types = NULL; | |
2771 */ | |
2772 | |
597 | 2773 slcf->enable = NGX_CONF_UNSET; |
2774 slcf->silent_errors = NGX_CONF_UNSET; | |
2775 slcf->ignore_recycled_buffers = NGX_CONF_UNSET; | |
2776 | |
2777 slcf->min_file_chunk = NGX_CONF_UNSET_SIZE; | |
2778 slcf->value_len = NGX_CONF_UNSET_SIZE; | |
2779 | |
2780 return slcf; | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2781 } |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2782 |
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2783 |
497 | 2784 static char * |
1169 | 2785 ngx_http_ssi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2786 { |
597 | 2787 ngx_http_ssi_loc_conf_t *prev = parent; |
2788 ngx_http_ssi_loc_conf_t *conf = child; | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2789 |
527 | 2790 ngx_str_t *type; |
2791 | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2792 ngx_conf_merge_value(conf->enable, prev->enable, 0); |
497 | 2793 ngx_conf_merge_value(conf->silent_errors, prev->silent_errors, 0); |
509 | 2794 ngx_conf_merge_value(conf->ignore_recycled_buffers, |
2795 prev->ignore_recycled_buffers, 0); | |
497 | 2796 |
2797 ngx_conf_merge_size_value(conf->min_file_chunk, prev->min_file_chunk, 1024); | |
241
3bfa496bc22e
nginx-0.0.1-2004-01-27-10:08:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
240
diff
changeset
|
2798 ngx_conf_merge_size_value(conf->value_len, prev->value_len, 256); |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2799 |
527 | 2800 if (conf->types == NULL) { |
2801 if (prev->types == NULL) { | |
2802 conf->types = ngx_array_create(cf->pool, 1, sizeof(ngx_str_t)); | |
2803 if (conf->types == NULL) { | |
2804 return NGX_CONF_ERROR; | |
2805 } | |
2806 | |
2807 type = ngx_array_push(conf->types); | |
2808 if (type == NULL) { | |
2809 return NGX_CONF_ERROR; | |
2810 } | |
2811 | |
2812 type->len = sizeof("text/html") - 1; | |
2813 type->data = (u_char *) "text/html"; | |
2814 | |
2815 } else { | |
2816 conf->types = prev->types; | |
2817 } | |
2818 } | |
2819 | |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2820 return NGX_CONF_OK; |
15
cbb38b60495c
nginx-0.0.1-2002-09-18-20:32:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
14
diff
changeset
|
2821 } |
14
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
2822 |
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
2823 |
497 | 2824 static ngx_int_t |
681 | 2825 ngx_http_ssi_filter_init(ngx_conf_t *cf) |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
2826 { |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2827 ngx_http_next_header_filter = ngx_http_top_header_filter; |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
2828 ngx_http_top_header_filter = ngx_http_ssi_header_filter; |
14
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
2829 |
239
574bea0142be
nginx-0.0.1-2004-01-26-11:52:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
131
diff
changeset
|
2830 ngx_http_next_body_filter = ngx_http_top_body_filter; |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
2831 ngx_http_top_body_filter = ngx_http_ssi_body_filter; |
14
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
2832 |
125
885ffb8cc32a
nginx-0.0.1-2003-08-06-09:30:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
16
diff
changeset
|
2833 return NGX_OK; |
14
f8a0d0f31a24
nginx-0.0.1-2002-09-17-21:49:32 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
2834 } |