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