Mercurial > hg > nginx
comparison src/core/ngx_string.c @ 5389:72e31d88defa
Added ngx_filename_cmp() with "/" sorted to the left.
This patch fixes incorrect handling of auto redirect in configurations
like:
location /0 { }
location /a- { }
location /a/ { proxy_pass ... }
With previously used sorting, this resulted in the following locations
tree (as "-" is less than "/"):
"/a-"
"/0" "/a/"
and a request to "/a" didn't match "/a/" with auto_redirect, as it
didn't traverse relevant tree node during lookup (it tested "/a-",
then "/0", and then falled back to null location).
To preserve locale use for non-ASCII characters on case-insensetive
systems, libc's tolower() used.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 23 Sep 2013 19:37:13 +0400 |
parents | 670ceaba03d8 |
children | a602e1006579 |
comparison
equal
deleted
inserted
replaced
5388:fbaae7d1c033 | 5389:72e31d88defa |
---|---|
851 } | 851 } |
852 } | 852 } |
853 | 853 |
854 | 854 |
855 ngx_int_t | 855 ngx_int_t |
856 ngx_filename_cmp(u_char *s1, u_char *s2, size_t n) | |
857 { | |
858 ngx_uint_t c1, c2; | |
859 | |
860 while (n) { | |
861 c1 = (ngx_uint_t) *s1++; | |
862 c2 = (ngx_uint_t) *s2++; | |
863 | |
864 #if (NGX_HAVE_CASELESS_FILESYSTEM) | |
865 c1 = tolower(c1); | |
866 c2 = tolower(c2); | |
867 #endif | |
868 | |
869 if (c1 == c2) { | |
870 | |
871 if (c1) { | |
872 n--; | |
873 continue; | |
874 } | |
875 | |
876 return 0; | |
877 } | |
878 | |
879 /* we need '/' to be the lowest character */ | |
880 | |
881 if (c1 == 0 || c2 == 0) { | |
882 return c1 - c2; | |
883 } | |
884 | |
885 c1 = (c1 == '/') ? 0 : c1; | |
886 c2 = (c2 == '/') ? 0 : c2; | |
887 | |
888 return c1 - c2; | |
889 } | |
890 | |
891 return 0; | |
892 } | |
893 | |
894 | |
895 ngx_int_t | |
856 ngx_atoi(u_char *line, size_t n) | 896 ngx_atoi(u_char *line, size_t n) |
857 { | 897 { |
858 ngx_int_t value; | 898 ngx_int_t value; |
859 | 899 |
860 if (n == 0) { | 900 if (n == 0) { |