Mercurial > hg > nginx-vendor-0-7
diff src/http/modules/ngx_http_referer_module.c @ 358:9121a0a91f47 NGINX_0_6_23
nginx 0.6.23
*) Change: the "off" parameter in the "ssl_session_cache" directive;
now this is default parameter.
*) Change: the "open_file_cache_retest" directive was renamed to the
"open_file_cache_valid".
*) Feature: the "open_file_cache_min_uses" directive.
*) Feature: the ngx_http_gzip_static_module.
*) Feature: the "gzip_disable" directive.
*) Feature: the "memcached_pass" directive may be used inside the "if"
block.
*) Bugfix: a segmentation fault occurred in worker process, if the
"memcached_pass" and "if" directives were used in the same location.
*) Bugfix: if a "satisfy_any on" directive was used and not all access
and auth modules directives were set, then other given access and
auth directives were not tested;
*) Bugfix: regex parameters in a "valid_referers" directive were not
inherited from previous level.
*) Bugfix: a "post_action" directive did run if a request was completed
with 499 status code.
*) Bugfix: optimization of 16K buffer usage in a SSL connection.
Thanks to Ben Maurer.
*) Bugfix: the STARTTLS in SMTP mode did not work.
Thanks to Oleg Motienko.
*) Bugfix: in HTTPS mode requests might fail with the "bad write retry"
error; bug appeared in 0.5.13.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Thu, 27 Dec 2007 00:00:00 +0300 |
parents | b743d290eb3b |
children | 54fad6c4b555 |
line wrap: on
line diff
--- a/src/http/modules/ngx_http_referer_module.c +++ b/src/http/modules/ngx_http_referer_module.c @@ -11,14 +11,7 @@ #define NGX_HTTP_REFERER_NO_URI_PART ((void *) 4) -#if (NGX_PCRE) - -typedef struct { - ngx_regex_t *regex; - ngx_str_t name; -} ngx_http_referer_regex_t; - -#else +#if !(NGX_PCRE) #define ngx_regex_t void @@ -168,34 +161,23 @@ ngx_http_referer_variable(ngx_http_reque #if (NGX_PCRE) if (rlcf->regex) { - ngx_int_t n; - ngx_str_t referer; - ngx_http_referer_regex_t *regex; + ngx_int_t rc; + ngx_str_t referer; referer.len = len - 7; referer.data = ref; - regex = rlcf->regex->elts; - - for (i = 0; i < rlcf->regex->nelts; i++) { - n = ngx_regex_exec(regex[i].regex, &referer, NULL, 0); - - if (n == NGX_REGEX_NO_MATCHED) { - continue; - } + rc = ngx_regex_exec_array(rlcf->regex, &referer, r->connection->log); - if (n < 0) { - ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, - ngx_regex_exec_n - " failed: %d on \"%V\" using \"%V\"", - n, &referer, ®ex[i].name); - return NGX_ERROR; - } - - /* match */ - + if (rc == NGX_OK) { goto valid; } + + if (rc == NGX_ERROR) { + return rc; + } + + /* NGX_DECLINED */ } #endif @@ -242,6 +224,10 @@ ngx_http_referer_create_conf(ngx_conf_t return NGX_CONF_ERROR; } +#if (NGX_PCRE) + conf->regex = NGX_CONF_UNSET_PTR; +#endif + conf->no_referer = NGX_CONF_UNSET; conf->blocked_referer = NGX_CONF_UNSET; @@ -260,6 +246,7 @@ ngx_http_referer_merge_conf(ngx_conf_t * if (conf->keys == NULL) { conf->hash = prev->hash; + ngx_conf_merge_ptr_value(conf->regex, prev->regex, NULL); ngx_conf_merge_value(conf->no_referer, prev->no_referer, 0); ngx_conf_merge_value(conf->blocked_referer, prev->blocked_referer, 0); @@ -335,6 +322,8 @@ ngx_http_referer_merge_conf(ngx_conf_t * conf->hash.wc_tail = (ngx_hash_wildcard_t *) hash.hash; } + ngx_conf_merge_ptr_value(conf->regex, prev->regex, NULL); + if (conf->no_referer == NGX_CONF_UNSET) { conf->no_referer = 0; } @@ -509,26 +498,25 @@ ngx_http_add_regex_referer(ngx_conf_t *c ngx_str_t *name, ngx_regex_t *regex) { #if (NGX_PCRE) - ngx_str_t err; - ngx_http_referer_regex_t *rr; - u_char errstr[NGX_MAX_CONF_ERRSTR]; + ngx_str_t err; + ngx_regex_elt_t *re; + u_char errstr[NGX_MAX_CONF_ERRSTR]; - if (rlcf->regex == NULL) { - rlcf->regex = ngx_array_create(cf->pool, 2, - sizeof(ngx_http_referer_regex_t)); + if (rlcf->regex == NGX_CONF_UNSET_PTR) { + rlcf->regex = ngx_array_create(cf->pool, 2, sizeof(ngx_regex_elt_t)); if (rlcf->regex == NULL) { return NGX_CONF_ERROR; } } - rr = ngx_array_push(rlcf->regex); - if (rr == NULL) { + re = ngx_array_push(rlcf->regex); + if (re == NULL) { return NGX_CONF_ERROR; } if (regex) { - rr->regex = regex; - rr->name = *name; + re->regex = regex; + re->name = name->data; return NGX_CONF_OK; } @@ -539,14 +527,14 @@ ngx_http_add_regex_referer(ngx_conf_t *c name->len--; name->data++; - rr->regex = ngx_regex_compile(name, NGX_REGEX_CASELESS, cf->pool, &err); + re->regex = ngx_regex_compile(name, NGX_REGEX_CASELESS, cf->pool, &err); - if (rr->regex == NULL) { + if (re->regex == NULL) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "%s", err.data); return NGX_CONF_ERROR; } - rr->name = *name; + re->name = name->data; return NGX_CONF_OK;