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