Klaus Demo nginx / 8decab3
merge_slashes Igor Sysoev 14 years ago
5 changed file(s) with 26 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
6363 #endif
6464
6565 ngx_int_t ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b);
66 ngx_int_t ngx_http_parse_complex_uri(ngx_http_request_t *r);
66 ngx_int_t ngx_http_parse_complex_uri(ngx_http_request_t *r,
67 ngx_uint_t merge_slashes);
6768 ngx_int_t ngx_http_parse_unsafe_uri(ngx_http_request_t *r, ngx_str_t *uri,
6869 ngx_str_t *args, ngx_uint_t *flags);
6970 ngx_int_t ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b);
184184 offsetof(ngx_http_core_srv_conf_t, ignore_invalid_headers),
185185 NULL },
186186
187 { ngx_string("merge_slashes"),
188 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG,
189 ngx_conf_set_flag_slot,
190 NGX_HTTP_SRV_CONF_OFFSET,
191 offsetof(ngx_http_core_srv_conf_t, merge_slashes),
192 NULL },
193
187194 { ngx_string("location"),
188195 NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_BLOCK|NGX_CONF_TAKE12,
189196 ngx_http_core_location,
22322239 cscf->client_header_buffer_size = NGX_CONF_UNSET_SIZE;
22332240 cscf->optimize_server_names = NGX_CONF_UNSET;
22342241 cscf->ignore_invalid_headers = NGX_CONF_UNSET;
2242 cscf->merge_slashes = NGX_CONF_UNSET;
22352243
22362244 return cscf;
22372245 }
23232331
23242332 ngx_conf_merge_value(conf->ignore_invalid_headers,
23252333 prev->ignore_invalid_headers, 1);
2334
2335 ngx_conf_merge_value(conf->merge_slashes, prev->merge_slashes, 1);
23262336
23272337 return NGX_CONF_OK;
23282338 }
142142
143143 ngx_flag_t optimize_server_names;
144144 ngx_flag_t ignore_invalid_headers;
145 ngx_flag_t merge_slashes;
145146 } ngx_http_core_srv_conf_t;
146147
147148
907907
908908
909909 ngx_int_t
910 ngx_http_parse_complex_uri(ngx_http_request_t *r)
910 ngx_http_parse_complex_uri(ngx_http_request_t *r, ngx_uint_t merge_slashes)
911911 {
912912 u_char c, ch, decoded, *p, *u;
913913 enum {
10151015 switch(ch) {
10161016 #if (NGX_WIN32)
10171017 case '\\':
1018 break;
10181019 #endif
10191020 case '/':
1021 if (merge_slashes) {
1022 *u++ = ch;
1023 }
10201024 break;
10211025 case '.':
10221026 state = sw_dot;
601601 static void
602602 ngx_http_process_request_line(ngx_event_t *rev)
603603 {
604 ssize_t n;
605 ngx_int_t rc, rv;
606 ngx_connection_t *c;
607 ngx_http_request_t *r;
604 ssize_t n;
605 ngx_int_t rc, rv;
606 ngx_connection_t *c;
607 ngx_http_request_t *r;
608 ngx_http_core_srv_conf_t *cscf;
608609
609610 c = rev->data;
610611 r = c->data;
656657 return;
657658 }
658659
659 rc = ngx_http_parse_complex_uri(r);
660 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
661
662 rc = ngx_http_parse_complex_uri(r, cscf->merge_slashes);
660663
661664 if (rc == NGX_HTTP_PARSE_INVALID_REQUEST) {
662665 ngx_log_error(NGX_LOG_INFO, c->log, 0,