Mercurial > hg > nginx
comparison src/http/ngx_http.c @ 7848:1bde031b59ff
Location header escaping in redirects (ticket #882).
The header is escaped in redirects based on request URI or
location name (auto redirect).
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Mon, 24 May 2021 21:55:20 +0300 |
parents | 4e141d0816d4 |
children | 61abb35bb8cf d514f88053e5 |
comparison
equal
deleted
inserted
replaced
7847:1336a33cff33 | 7848:1bde031b59ff |
---|---|
35 ngx_uint_t ctx_index); | 35 ngx_uint_t ctx_index); |
36 static ngx_int_t ngx_http_init_locations(ngx_conf_t *cf, | 36 static ngx_int_t ngx_http_init_locations(ngx_conf_t *cf, |
37 ngx_http_core_srv_conf_t *cscf, ngx_http_core_loc_conf_t *pclcf); | 37 ngx_http_core_srv_conf_t *cscf, ngx_http_core_loc_conf_t *pclcf); |
38 static ngx_int_t ngx_http_init_static_location_trees(ngx_conf_t *cf, | 38 static ngx_int_t ngx_http_init_static_location_trees(ngx_conf_t *cf, |
39 ngx_http_core_loc_conf_t *pclcf); | 39 ngx_http_core_loc_conf_t *pclcf); |
40 static ngx_int_t ngx_http_escape_location_name(ngx_conf_t *cf, | |
41 ngx_http_core_loc_conf_t *clcf); | |
40 static ngx_int_t ngx_http_cmp_locations(const ngx_queue_t *one, | 42 static ngx_int_t ngx_http_cmp_locations(const ngx_queue_t *one, |
41 const ngx_queue_t *two); | 43 const ngx_queue_t *two); |
42 static ngx_int_t ngx_http_join_exact_locations(ngx_conf_t *cf, | 44 static ngx_int_t ngx_http_join_exact_locations(ngx_conf_t *cf, |
43 ngx_queue_t *locations); | 45 ngx_queue_t *locations); |
44 static void ngx_http_create_locations_list(ngx_queue_t *locations, | 46 static void ngx_http_create_locations_list(ngx_queue_t *locations, |
880 | 882 |
881 ngx_queue_init(&lq->list); | 883 ngx_queue_init(&lq->list); |
882 | 884 |
883 ngx_queue_insert_tail(*locations, &lq->queue); | 885 ngx_queue_insert_tail(*locations, &lq->queue); |
884 | 886 |
887 if (ngx_http_escape_location_name(cf, clcf) != NGX_OK) { | |
888 return NGX_ERROR; | |
889 } | |
890 | |
891 return NGX_OK; | |
892 } | |
893 | |
894 | |
895 static ngx_int_t | |
896 ngx_http_escape_location_name(ngx_conf_t *cf, ngx_http_core_loc_conf_t *clcf) | |
897 { | |
898 u_char *p; | |
899 size_t len; | |
900 uintptr_t escape; | |
901 | |
902 escape = 2 * ngx_escape_uri(NULL, clcf->name.data, clcf->name.len, | |
903 NGX_ESCAPE_URI); | |
904 | |
905 if (escape) { | |
906 len = clcf->name.len + escape; | |
907 | |
908 p = ngx_pnalloc(cf->pool, len); | |
909 if (p == NULL) { | |
910 return NGX_ERROR; | |
911 } | |
912 | |
913 clcf->escaped_name.len = len; | |
914 clcf->escaped_name.data = p; | |
915 | |
916 ngx_escape_uri(p, clcf->name.data, clcf->name.len, NGX_ESCAPE_URI); | |
917 | |
918 } else { | |
919 clcf->escaped_name = clcf->name; | |
920 } | |
921 | |
885 return NGX_OK; | 922 return NGX_OK; |
886 } | 923 } |
887 | 924 |
888 | 925 |
889 static ngx_int_t | 926 static ngx_int_t |