version 1.1.1.2, 2014/06/15 20:20:06
|
version 1.1.1.3, 2016/11/02 10:35:00
|
Line 1
|
Line 1
|
|
#include "first.h" |
|
|
#include "base.h" |
#include "base.h" |
#include "log.h" |
#include "log.h" |
#include "buffer.h" |
#include "buffer.h" |
Line 47 FREE_FUNC(mod_redirect_free) {
|
Line 49 FREE_FUNC(mod_redirect_free) {
|
for (i = 0; i < srv->config_context->used; i++) { |
for (i = 0; i < srv->config_context->used; i++) { |
plugin_config *s = p->config_storage[i]; |
plugin_config *s = p->config_storage[i]; |
|
|
|
if (NULL == s) continue; |
|
|
pcre_keyvalue_buffer_free(s->redirect); |
pcre_keyvalue_buffer_free(s->redirect); |
|
|
free(s); |
free(s); |
Line 79 SETDEFAULTS_FUNC(mod_redirect_set_defaults) {
|
Line 83 SETDEFAULTS_FUNC(mod_redirect_set_defaults) {
|
p->config_storage = calloc(1, srv->config_context->used * sizeof(plugin_config *)); |
p->config_storage = calloc(1, srv->config_context->used * sizeof(plugin_config *)); |
|
|
for (i = 0; i < srv->config_context->used; i++) { |
for (i = 0; i < srv->config_context->used; i++) { |
|
data_config const* config = (data_config const*)srv->config_context->data[i]; |
plugin_config *s; |
plugin_config *s; |
size_t j; |
size_t j; |
array *ca; |
|
data_unset *du; |
data_unset *du; |
data_array *da; |
data_array *da; |
|
|
Line 93 SETDEFAULTS_FUNC(mod_redirect_set_defaults) {
|
Line 97 SETDEFAULTS_FUNC(mod_redirect_set_defaults) {
|
cv[1].destination = &(s->redirect_code); |
cv[1].destination = &(s->redirect_code); |
|
|
p->config_storage[i] = s; |
p->config_storage[i] = s; |
ca = ((data_config *)srv->config_context->data[i])->value; |
|
|
|
if (0 != config_insert_values_global(srv, ca, cv)) { | if (0 != config_insert_values_global(srv, config->value, cv, i == 0 ? T_CONFIG_SCOPE_SERVER : T_CONFIG_SCOPE_CONNECTION)) { |
return HANDLER_ERROR; |
return HANDLER_ERROR; |
} |
} |
|
|
if (NULL == (du = array_get_element(ca, "url.redirect"))) { | if (NULL == (du = array_get_element(config->value, "url.redirect"))) { |
/* no url.redirect defined */ |
/* no url.redirect defined */ |
continue; |
continue; |
} |
} |
Line 129 SETDEFAULTS_FUNC(mod_redirect_set_defaults) {
|
Line 132 SETDEFAULTS_FUNC(mod_redirect_set_defaults) {
|
|
|
log_error_write(srv, __FILE__, __LINE__, "sb", |
log_error_write(srv, __FILE__, __LINE__, "sb", |
"pcre-compile failed for", da->value->data[j]->key); |
"pcre-compile failed for", da->value->data[j]->key); |
|
return HANDLER_ERROR; |
} |
} |
} |
} |
} |
} |
Line 182 static handler_t mod_redirect_uri_handler(server *srv,
|
Line 186 static handler_t mod_redirect_uri_handler(server *srv,
|
|
|
mod_redirect_patch_connection(srv, con, p); |
mod_redirect_patch_connection(srv, con, p); |
|
|
buffer_copy_string_buffer(p->match_buf, con->request.uri); | buffer_copy_buffer(p->match_buf, con->request.uri); |
|
|
for (i = 0; i < p->conf.redirect->used; i++) { |
for (i = 0; i < p->conf.redirect->used; i++) { |
pcre *match; |
pcre *match; |
Line 197 static handler_t mod_redirect_uri_handler(server *srv,
|
Line 201 static handler_t mod_redirect_uri_handler(server *srv,
|
match = kv->key; |
match = kv->key; |
extra = kv->key_extra; |
extra = kv->key_extra; |
pattern = kv->value->ptr; |
pattern = kv->value->ptr; |
pattern_len = kv->value->used - 1; | pattern_len = buffer_string_length(kv->value); |
|
|
if ((n = pcre_exec(match, extra, p->match_buf->ptr, p->match_buf->used - 1, 0, 0, ovec, 3 * N)) < 0) { | if ((n = pcre_exec(match, extra, CONST_BUF_LEN(p->match_buf), 0, 0, ovec, 3 * N)) < 0) { |
if (n != PCRE_ERROR_NOMATCH) { |
if (n != PCRE_ERROR_NOMATCH) { |
log_error_write(srv, __FILE__, __LINE__, "sd", |
log_error_write(srv, __FILE__, __LINE__, "sd", |
"execution error while matching: ", n); |
"execution error while matching: ", n); |
return HANDLER_ERROR; |
return HANDLER_ERROR; |
} |
} |
|
} else if (0 == pattern_len) { |
|
/* short-circuit if blank replacement pattern |
|
* (do not attempt to match against remaining redirect rules) */ |
|
return HANDLER_GO_ON; |
} else { |
} else { |
const char **list; |
const char **list; |
size_t start; |
size_t start; |