mirror of
https://github.com/nginx/nginx.git
synced 2025-06-30 03:00:38 +08:00
merge_slashes
This commit is contained in:
parent
4c5207fd56
commit
8decab3dd9
@ -64,7 +64,8 @@ int ngx_http_ssl_servername(ngx_ssl_conn_t *ssl_conn, int *ad, void *arg);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
ngx_int_t ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b);
|
ngx_int_t ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b);
|
||||||
ngx_int_t ngx_http_parse_complex_uri(ngx_http_request_t *r);
|
ngx_int_t ngx_http_parse_complex_uri(ngx_http_request_t *r,
|
||||||
|
ngx_uint_t merge_slashes);
|
||||||
ngx_int_t ngx_http_parse_unsafe_uri(ngx_http_request_t *r, ngx_str_t *uri,
|
ngx_int_t ngx_http_parse_unsafe_uri(ngx_http_request_t *r, ngx_str_t *uri,
|
||||||
ngx_str_t *args, ngx_uint_t *flags);
|
ngx_str_t *args, ngx_uint_t *flags);
|
||||||
ngx_int_t ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b);
|
ngx_int_t ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b);
|
||||||
|
@ -185,6 +185,13 @@ static ngx_command_t ngx_http_core_commands[] = {
|
|||||||
offsetof(ngx_http_core_srv_conf_t, ignore_invalid_headers),
|
offsetof(ngx_http_core_srv_conf_t, ignore_invalid_headers),
|
||||||
NULL },
|
NULL },
|
||||||
|
|
||||||
|
{ ngx_string("merge_slashes"),
|
||||||
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG,
|
||||||
|
ngx_conf_set_flag_slot,
|
||||||
|
NGX_HTTP_SRV_CONF_OFFSET,
|
||||||
|
offsetof(ngx_http_core_srv_conf_t, merge_slashes),
|
||||||
|
NULL },
|
||||||
|
|
||||||
{ ngx_string("location"),
|
{ ngx_string("location"),
|
||||||
NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_BLOCK|NGX_CONF_TAKE12,
|
NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_BLOCK|NGX_CONF_TAKE12,
|
||||||
ngx_http_core_location,
|
ngx_http_core_location,
|
||||||
@ -2233,6 +2240,7 @@ ngx_http_core_create_srv_conf(ngx_conf_t *cf)
|
|||||||
cscf->client_header_buffer_size = NGX_CONF_UNSET_SIZE;
|
cscf->client_header_buffer_size = NGX_CONF_UNSET_SIZE;
|
||||||
cscf->optimize_server_names = NGX_CONF_UNSET;
|
cscf->optimize_server_names = NGX_CONF_UNSET;
|
||||||
cscf->ignore_invalid_headers = NGX_CONF_UNSET;
|
cscf->ignore_invalid_headers = NGX_CONF_UNSET;
|
||||||
|
cscf->merge_slashes = NGX_CONF_UNSET;
|
||||||
|
|
||||||
return cscf;
|
return cscf;
|
||||||
}
|
}
|
||||||
@ -2325,6 +2333,8 @@ ngx_http_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||||||
ngx_conf_merge_value(conf->ignore_invalid_headers,
|
ngx_conf_merge_value(conf->ignore_invalid_headers,
|
||||||
prev->ignore_invalid_headers, 1);
|
prev->ignore_invalid_headers, 1);
|
||||||
|
|
||||||
|
ngx_conf_merge_value(conf->merge_slashes, prev->merge_slashes, 1);
|
||||||
|
|
||||||
return NGX_CONF_OK;
|
return NGX_CONF_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,6 +143,7 @@ typedef struct {
|
|||||||
|
|
||||||
ngx_flag_t optimize_server_names;
|
ngx_flag_t optimize_server_names;
|
||||||
ngx_flag_t ignore_invalid_headers;
|
ngx_flag_t ignore_invalid_headers;
|
||||||
|
ngx_flag_t merge_slashes;
|
||||||
} ngx_http_core_srv_conf_t;
|
} ngx_http_core_srv_conf_t;
|
||||||
|
|
||||||
|
|
||||||
|
@ -908,7 +908,7 @@ header_done:
|
|||||||
|
|
||||||
|
|
||||||
ngx_int_t
|
ngx_int_t
|
||||||
ngx_http_parse_complex_uri(ngx_http_request_t *r)
|
ngx_http_parse_complex_uri(ngx_http_request_t *r, ngx_uint_t merge_slashes)
|
||||||
{
|
{
|
||||||
u_char c, ch, decoded, *p, *u;
|
u_char c, ch, decoded, *p, *u;
|
||||||
enum {
|
enum {
|
||||||
@ -1016,8 +1016,12 @@ ngx_http_parse_complex_uri(ngx_http_request_t *r)
|
|||||||
switch(ch) {
|
switch(ch) {
|
||||||
#if (NGX_WIN32)
|
#if (NGX_WIN32)
|
||||||
case '\\':
|
case '\\':
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
case '/':
|
case '/':
|
||||||
|
if (merge_slashes) {
|
||||||
|
*u++ = ch;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case '.':
|
case '.':
|
||||||
state = sw_dot;
|
state = sw_dot;
|
||||||
|
@ -606,6 +606,7 @@ ngx_http_process_request_line(ngx_event_t *rev)
|
|||||||
ngx_int_t rc, rv;
|
ngx_int_t rc, rv;
|
||||||
ngx_connection_t *c;
|
ngx_connection_t *c;
|
||||||
ngx_http_request_t *r;
|
ngx_http_request_t *r;
|
||||||
|
ngx_http_core_srv_conf_t *cscf;
|
||||||
|
|
||||||
c = rev->data;
|
c = rev->data;
|
||||||
r = c->data;
|
r = c->data;
|
||||||
@ -657,7 +658,9 @@ ngx_http_process_request_line(ngx_event_t *rev)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ngx_http_parse_complex_uri(r);
|
cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
|
||||||
|
|
||||||
|
rc = ngx_http_parse_complex_uri(r, cscf->merge_slashes);
|
||||||
|
|
||||||
if (rc == NGX_HTTP_PARSE_INVALID_REQUEST) {
|
if (rc == NGX_HTTP_PARSE_INVALID_REQUEST) {
|
||||||
ngx_log_error(NGX_LOG_INFO, c->log, 0,
|
ngx_log_error(NGX_LOG_INFO, c->log, 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user