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