comparison src/http/ngx_http.c @ 5388:fbaae7d1c033

Caseless location tree construction (ticket #90). Location tree was always constructed using case-sensitive comparison, even on case-insensitive systems. This resulted in incorrect operation if uppercase letters were used in location directives. Notably, the following config: location /a { ... } location /B { ... } failed to properly map requests to "/B" into "location /B".
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 23 Sep 2013 19:37:06 +0400
parents 5482671df278
children 692afcea9d0d
comparison
equal deleted inserted replaced
5387:0fbcfab0bfd7 5388:fbaae7d1c033
947 return 0; 947 return 0;
948 } 948 }
949 949
950 #endif 950 #endif
951 951
952 rc = ngx_strcmp(first->name.data, second->name.data); 952 rc = ngx_filename_cmp(first->name.data, second->name.data,
953 ngx_min(first->name.len, second->name.len) + 1);
953 954
954 if (rc == 0 && !first->exact_match && second->exact_match) { 955 if (rc == 0 && !first->exact_match && second->exact_match) {
955 /* an exact match must be before the same inclusive one */ 956 /* an exact match must be before the same inclusive one */
956 return 1; 957 return 1;
957 } 958 }
973 x = ngx_queue_next(q); 974 x = ngx_queue_next(q);
974 975
975 lq = (ngx_http_location_queue_t *) q; 976 lq = (ngx_http_location_queue_t *) q;
976 lx = (ngx_http_location_queue_t *) x; 977 lx = (ngx_http_location_queue_t *) x;
977 978
978 if (ngx_strcmp(lq->name->data, lx->name->data) == 0) { 979 if (lq->name->len == lx->name->len
979 980 && ngx_filename_cmp(lq->name->data, lx->name->data, lx->name->len)
981 == 0)
982 {
980 if ((lq->exact && lx->exact) || (lq->inclusive && lx->inclusive)) { 983 if ((lq->exact && lx->exact) || (lq->inclusive && lx->inclusive)) {
981 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, 984 ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
982 "duplicate location \"%V\" in %s:%ui", 985 "duplicate location \"%V\" in %s:%ui",
983 lx->name, lx->file_name, lx->line); 986 lx->name, lx->file_name, lx->line);
984 987
1026 x = ngx_queue_next(x)) 1029 x = ngx_queue_next(x))
1027 { 1030 {
1028 lx = (ngx_http_location_queue_t *) x; 1031 lx = (ngx_http_location_queue_t *) x;
1029 1032
1030 if (len > lx->name->len 1033 if (len > lx->name->len
1031 || (ngx_strncmp(name, lx->name->data, len) != 0)) 1034 || ngx_filename_cmp(name, lx->name->data, len) != 0)
1032 { 1035 {
1033 break; 1036 break;
1034 } 1037 }
1035 } 1038 }
1036 1039