comparison src/http/modules/ngx_http_ssi_filter_module.c @ 158:2d15b82126ed NGINX_0_3_26

nginx 0.3.26 *) Change: the "optimize_host_names" directive was renamed to the "optimize_server_names". *) Bugfix: if in the "proxy_pass" directive was no the URI part, then the main request URI was transferred to a backend while proxying the SSI subrequest.
author Igor Sysoev <http://sysoev.ru>
date Fri, 03 Feb 2006 00:00:00 +0300
parents ea622d8acb38
children 73e8476f9142
comparison
equal deleted inserted replaced
157:10bd259db2a7 158:2d15b82126ed
759 759
760 760
761 static ngx_int_t 761 static ngx_int_t
762 ngx_http_ssi_parse(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx) 762 ngx_http_ssi_parse(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx)
763 { 763 {
764 u_char *p, *last, *copy_end, ch; 764 u_char *p, *value, *last, *copy_end, ch;
765 size_t looked; 765 size_t looked;
766 ngx_http_ssi_state_e state; 766 ngx_http_ssi_state_e state;
767 767
768 state = ctx->state; 768 state = ctx->state;
769 looked = ctx->looked; 769 looked = ctx->looked;
912 break; 912 break;
913 913
914 default: 914 default:
915 ctx->command.len = 1; 915 ctx->command.len = 1;
916 ctx->command.data = ngx_palloc(r->pool, 916 ctx->command.data = ngx_palloc(r->pool,
917 NGX_HTTP_SSI_COMMAND_LEN + 1); 917 NGX_HTTP_SSI_COMMAND_LEN);
918 if (ctx->command.data == NULL) { 918 if (ctx->command.data == NULL) {
919 return NGX_ERROR; 919 return NGX_ERROR;
920 } 920 }
921 921
922 ctx->command.data[0] = ch; 922 ctx->command.data[0] = ch;
923
923 ctx->key = 0; 924 ctx->key = 0;
924 ctx->key = ngx_hash(ctx->key, ch); 925 ctx->key = ngx_hash(ctx->key, ch);
925 926
926 ctx->params.nelts = 0; 927 ctx->params.nelts = 0;
927 state = ssi_command_state; 928 state = ssi_command_state;
942 case '-': 943 case '-':
943 state = ssi_comment_end0_state; 944 state = ssi_comment_end0_state;
944 break; 945 break;
945 946
946 default: 947 default:
948 if (ctx->command.len == NGX_HTTP_SSI_COMMAND_LEN) {
949 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
950 "the \"%V%c...\" SSI command is too long",
951 &ctx->command, ch);
952
953 state = ssi_error_state;
954 break;
955 }
956
947 ctx->command.data[ctx->command.len++] = ch; 957 ctx->command.data[ctx->command.len++] = ch;
948 ctx->key = ngx_hash(ctx->key, ch); 958 ctx->key = ngx_hash(ctx->key, ch);
949
950 if (ctx->command.len == NGX_HTTP_SSI_COMMAND_LEN) {
951 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
952 "the \"%V\" SSI command is too long",
953 &ctx->command);
954
955 state = ssi_error_state;
956 break;
957 }
958 } 959 }
959 960
960 break; 961 break;
961 962
962 case ssi_preparam_state: 963 case ssi_preparam_state:
977 return NGX_ERROR; 978 return NGX_ERROR;
978 } 979 }
979 980
980 ctx->param->key.len = 1; 981 ctx->param->key.len = 1;
981 ctx->param->key.data = ngx_palloc(r->pool, 982 ctx->param->key.data = ngx_palloc(r->pool,
982 NGX_HTTP_SSI_PARAM_LEN + 1); 983 NGX_HTTP_SSI_PARAM_LEN);
983 if (ctx->param->key.data == NULL) { 984 if (ctx->param->key.data == NULL) {
984 return NGX_ERROR; 985 return NGX_ERROR;
985 } 986 }
986 987
987 ctx->param->key.data[0] = ch; 988 ctx->param->key.data[0] = ch;
988 989
989 ctx->param->value.len = 0; 990 ctx->param->value.len = 0;
990 ctx->param->value.data = ngx_palloc(r->pool, 991
991 ctx->value_len + 1); 992 if (ctx->value_buf == NULL) {
992 if (ctx->param->value.data == NULL) { 993 ctx->param->value.data = ngx_palloc(r->pool,
993 return NGX_ERROR; 994 ctx->value_len);
995 if (ctx->param->value.data == NULL) {
996 return NGX_ERROR;
997 }
998
999 } else {
1000 ctx->param->value.data = ctx->value_buf;
994 } 1001 }
995 1002
996 state = ssi_param_state; 1003 state = ssi_param_state;
997 break; 1004 break;
998 } 1005 }
1020 "invalid \"%V\" parameter in \"%V\" SSI command", 1027 "invalid \"%V\" parameter in \"%V\" SSI command",
1021 &ctx->param->key, &ctx->command); 1028 &ctx->param->key, &ctx->command);
1022 break; 1029 break;
1023 1030
1024 default: 1031 default:
1025 ctx->param->key.data[ctx->param->key.len++] = ch;
1026
1027 if (ctx->param->key.len == NGX_HTTP_SSI_PARAM_LEN) { 1032 if (ctx->param->key.len == NGX_HTTP_SSI_PARAM_LEN) {
1028 state = ssi_error_state; 1033 state = ssi_error_state;
1029 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, 1034 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
1030 "too long \"%V\" parameter in " 1035 "too long \"%V%c...\" parameter in "
1031 "\"%V\" SSI command", 1036 "\"%V\" SSI command",
1032 &ctx->param->key, &ctx->command); 1037 &ctx->param->key, ch, &ctx->command);
1033 break; 1038 break;
1034 } 1039 }
1040
1041 ctx->param->key.data[ctx->param->key.len++] = ch;
1035 } 1042 }
1036 1043
1037 break; 1044 break;
1038 1045
1039 case ssi_preequal_state: 1046 case ssi_preequal_state:
1107 state = ssi_quoted_symbol_state; 1114 state = ssi_quoted_symbol_state;
1108 1115
1109 /* fall through */ 1116 /* fall through */
1110 1117
1111 default: 1118 default:
1112 ctx->param->value.data[ctx->param->value.len++] = ch;
1113
1114 if (ctx->param->value.len == ctx->value_len) { 1119 if (ctx->param->value.len == ctx->value_len) {
1115 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, 1120 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
1116 "too long \"%V\" value of \"%V\" parameter " 1121 "too long \"%V%c...\" value of \"%V\" "
1117 "in \"%V\" SSI command", 1122 "parameter in \"%V\" SSI command",
1118 &ctx->param->value, &ctx->param->key, 1123 &ctx->param->value, ch, &ctx->param->key,
1119 &ctx->command); 1124 &ctx->command);
1120 state = ssi_error_state; 1125 state = ssi_error_state;
1121 break; 1126 break;
1122 } 1127 }
1128
1129 ctx->param->value.data[ctx->param->value.len++] = ch;
1123 } 1130 }
1124 1131
1125 break; 1132 break;
1126 1133
1127 case ssi_quoted_value_state: 1134 case ssi_quoted_value_state:
1135 state = ssi_quoted_symbol_state; 1142 state = ssi_quoted_symbol_state;
1136 1143
1137 /* fall through */ 1144 /* fall through */
1138 1145
1139 default: 1146 default:
1140 ctx->param->value.data[ctx->param->value.len++] = ch;
1141
1142 if (ctx->param->value.len == ctx->value_len) { 1147 if (ctx->param->value.len == ctx->value_len) {
1143 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, 1148 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
1144 "too long \"%V\" value of \"%V\" parameter " 1149 "too long \"%V%c...\" value of \"%V\" "
1145 "in \"%V\" SSI command", 1150 "parameter in \"%V\" SSI command",
1146 &ctx->param->value, &ctx->param->key, 1151 &ctx->param->value, ch, &ctx->param->key,
1147 &ctx->command); 1152 &ctx->command);
1148 state = ssi_error_state; 1153 state = ssi_error_state;
1149 break; 1154 break;
1150 } 1155 }
1156
1157 ctx->param->value.data[ctx->param->value.len++] = ch;
1151 } 1158 }
1152 1159
1153 break; 1160 break;
1154 1161
1155 case ssi_quoted_symbol_state: 1162 case ssi_quoted_symbol_state:
1167 if (ch == '\'' && state == ssi_quoted_value_state) { 1174 if (ch == '\'' && state == ssi_quoted_value_state) {
1168 ctx->param->value.data[ctx->param->value.len - 1] = ch; 1175 ctx->param->value.data[ctx->param->value.len - 1] = ch;
1169 break; 1176 break;
1170 } 1177 }
1171 1178
1179 if (ctx->param->value.len == ctx->value_len) {
1180 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
1181 "too long \"%V%c...\" value of \"%V\" "
1182 "parameter in \"%V\" SSI command",
1183 &ctx->param->value, ch, &ctx->param->key,
1184 &ctx->command);
1185 state = ssi_error_state;
1186 break;
1187 }
1188
1172 ctx->param->value.data[ctx->param->value.len++] = ch; 1189 ctx->param->value.data[ctx->param->value.len++] = ch;
1173 1190
1174 if (ctx->param->value.len == ctx->value_len) {
1175 if (ctx->param->value.len == ctx->value_len) {
1176 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
1177 "too long \"%V\" value of \"%V\" parameter "
1178 "in \"%V\" SSI command",
1179 &ctx->param->value, &ctx->param->key,
1180 &ctx->command);
1181 state = ssi_error_state;
1182 break;
1183 }
1184 }
1185
1186 break; 1191 break;
1187 1192
1188 case ssi_postparam_state: 1193 case ssi_postparam_state:
1194
1195 if (ctx->param->value.len < ctx->value_len / 2) {
1196 value = ngx_palloc(r->pool, ctx->param->value.len);
1197 if (value == NULL) {
1198 return NGX_ERROR;
1199 }
1200
1201 ngx_memcpy(value, ctx->param->value.data,
1202 ctx->param->value.len);
1203
1204 ctx->value_buf = ctx->param->value.data;
1205 ctx->param->value.data = value;
1206
1207 } else {
1208 ctx->value_buf = NULL;
1209 }
1210
1189 switch (ch) { 1211 switch (ch) {
1190 case ' ': 1212 case ' ':
1191 case CR: 1213 case CR:
1192 case LF: 1214 case LF:
1193 case '\t': 1215 case '\t':