Klaus Demo nginx / 9a61c9e
r3117, r3123, r3229 merge: server name related merges: *) If .domain.com, .sub.domain.com, and .domain-some.com were defined, then .sub.domain.com was matched by .domain.com: wildcard names hash was built incorrectly due to sorting order issue of "." vs "-". They were sorted as com.domain com.domain-some com.domain.sub while they should be sorted as com.domain com.domain.sub com.domain-some for correct hash building *) test space between "~" and regex in server_name and invalid_referers *) do not run regex for empty host name since regex always fails in this case, the bug had been introduced in r2196 Igor Sysoev 12 years ago
7 changed file(s) with 48 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
819819
820820
821821 ngx_int_t
822 ngx_dns_strcmp(u_char *s1, u_char *s2)
823 {
824 ngx_uint_t c1, c2;
825
826 for ( ;; ) {
827 c1 = (ngx_uint_t) *s1++;
828 c2 = (ngx_uint_t) *s2++;
829
830 c1 = (c1 >= 'A' && c1 <= 'Z') ? (c1 | 0x20) : c1;
831 c2 = (c2 >= 'A' && c2 <= 'Z') ? (c2 | 0x20) : c2;
832
833 if (c1 == c2) {
834
835 if (c1) {
836 continue;
837 }
838
839 return 0;
840 }
841
842 /* in ASCII '.' > '-', but we need '.' to be the lowest character */
843
844 c1 = (c1 == '.') ? ' ' : c1;
845 c2 = (c2 == '.') ? ' ' : c2;
846
847 return c1 - c2;
848 }
849 }
850
851
852 ngx_int_t
822853 ngx_atoi(u_char *line, size_t n)
823854 {
824855 ngx_int_t value;
157157 ngx_int_t ngx_rstrncmp(u_char *s1, u_char *s2, size_t n);
158158 ngx_int_t ngx_rstrncasecmp(u_char *s1, u_char *s2, size_t n);
159159 ngx_int_t ngx_memn2cmp(u_char *s1, u_char *s2, size_t n1, size_t n2);
160 ngx_int_t ngx_dns_strcmp(u_char *s1, u_char *s2);
160161
161162 ngx_int_t ngx_atoi(u_char *line, size_t n);
162163 ssize_t ngx_atosz(u_char *line, size_t n);
336336 first = (ngx_hash_key_t *) one;
337337 second = (ngx_hash_key_t *) two;
338338
339 return ngx_strcmp(first->key.data, second->key.data);
339 return ngx_dns_strcmp(first->key.data, second->key.data);
340340 }
341341
342342
505505 ngx_regex_elt_t *re;
506506 u_char errstr[NGX_MAX_CONF_ERRSTR];
507507
508 if (name->len == 1) {
509 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "empty regex in \"%V\"", name);
510 return NGX_CONF_ERROR;
511 }
512
508513 if (rlcf->regex == NGX_CONF_UNSET_PTR) {
509514 rlcf->regex = ngx_array_create(cf->pool, 2, sizeof(ngx_regex_elt_t));
510515 if (rlcf->regex == NULL) {
561566 first = (ngx_hash_key_t *) one;
562567 second = (ngx_hash_key_t *) two;
563568
564 return ngx_strcmp(first->key.data, second->key.data);
565 }
569 return ngx_dns_strcmp(first->key.data, second->key.data);
570 }
16001600 first = (ngx_hash_key_t *) one;
16011601 second = (ngx_hash_key_t *) two;
16021602
1603 return ngx_strcmp(first->key.data, second->key.data);
1603 return ngx_dns_strcmp(first->key.data, second->key.data);
16041604 }
16051605
16061606
35113511 ngx_str_t err;
35123512 u_char errstr[NGX_MAX_CONF_ERRSTR];
35133513
3514 if (value[i].len == 1) {
3515 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
3516 "empty regex in server name \"%V\"", &value[i]);
3517 return NGX_CONF_ERROR;
3518 }
3519
35143520 err.len = NGX_MAX_CONF_ERRSTR;
35153521 err.data = errstr;
35163522
16571657
16581658 #if (NGX_PCRE)
16591659
1660 if (r->virtual_names->nregex) {
1660 if (len && r->virtual_names->nregex) {
16611661 size_t ncaptures;
16621662 ngx_int_t n;
16631663 ngx_uint_t i;