Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/http
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2007-12-12 23:43:39 +0300
committerIgor Sysoev <igor@sysoev.ru>2007-12-12 23:43:39 +0300
commit932a8a18df48a7cde5b5163d3428414586bf7066 (patch)
tree69f647db0d2ee00f7ff7cd1515d7efe636017447 /src/http
parent5f9301abf71a3bb48a8864daa78a9dcfe8a6a27e (diff)
merge_slashes
Diffstat (limited to 'src/http')
-rw-r--r--src/http/ngx_http.h3
-rw-r--r--src/http/ngx_http_core_module.c10
-rw-r--r--src/http/ngx_http_core_module.h1
-rw-r--r--src/http/ngx_http_parse.c6
-rw-r--r--src/http/ngx_http_request.c13
5 files changed, 26 insertions, 7 deletions
diff --git a/src/http/ngx_http.h b/src/http/ngx_http.h
index 266873ad6..42213a2ca 100644
--- a/src/http/ngx_http.h
+++ b/src/http/ngx_http.h
@@ -64,7 +64,8 @@ int ngx_http_ssl_servername(ngx_ssl_conn_t *ssl_conn, int *ad, void *arg);
#endif
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_str_t *args, ngx_uint_t *flags);
ngx_int_t ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b);
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 7aa7516e0..dfa5fa587 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -183,6 +183,13 @@ static ngx_command_t ngx_http_core_commands[] = {
offsetof(ngx_http_core_srv_conf_t, ignore_invalid_headers),
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_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_BLOCK|NGX_CONF_TAKE12,
ngx_http_core_location,
@@ -2213,6 +2220,7 @@ ngx_http_core_create_srv_conf(ngx_conf_t *cf)
cscf->client_header_buffer_size = NGX_CONF_UNSET_SIZE;
cscf->optimize_server_names = NGX_CONF_UNSET;
cscf->ignore_invalid_headers = NGX_CONF_UNSET;
+ cscf->merge_slashes = NGX_CONF_UNSET;
return cscf;
}
@@ -2305,6 +2313,8 @@ ngx_http_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_conf_merge_value(conf->ignore_invalid_headers,
prev->ignore_invalid_headers, 1);
+ ngx_conf_merge_value(conf->merge_slashes, prev->merge_slashes, 1);
+
return NGX_CONF_OK;
}
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index 79cd1f653..4425d3981 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -143,6 +143,7 @@ typedef struct {
ngx_flag_t optimize_server_names;
ngx_flag_t ignore_invalid_headers;
+ ngx_flag_t merge_slashes;
} ngx_http_core_srv_conf_t;
diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c
index 40e7700d3..256bd9be9 100644
--- a/src/http/ngx_http_parse.c
+++ b/src/http/ngx_http_parse.c
@@ -908,7 +908,7 @@ header_done:
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;
enum {
@@ -1016,8 +1016,12 @@ ngx_http_parse_complex_uri(ngx_http_request_t *r)
switch(ch) {
#if (NGX_WIN32)
case '\\':
+ break;
#endif
case '/':
+ if (merge_slashes) {
+ *u++ = ch;
+ }
break;
case '.':
state = sw_dot;
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 70434dcb3..0af46337e 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -603,10 +603,11 @@ ngx_http_ssl_servername(ngx_ssl_conn_t *ssl_conn, int *ad, void *arg)
static void
ngx_http_process_request_line(ngx_event_t *rev)
{
- ssize_t n;
- ngx_int_t rc, rv;
- ngx_connection_t *c;
- ngx_http_request_t *r;
+ ssize_t n;
+ ngx_int_t rc, rv;
+ ngx_connection_t *c;
+ ngx_http_request_t *r;
+ ngx_http_core_srv_conf_t *cscf;
c = rev->data;
r = c->data;
@@ -658,7 +659,9 @@ ngx_http_process_request_line(ngx_event_t *rev)
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) {
ngx_log_error(NGX_LOG_INFO, c->log, 0,