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