Browse Source

[core] defer pcre_compile until after config parse

master
Glenn Strauss 9 months ago
parent
commit
8845e1e67e
  1. 18
      src/configfile.c
  2. 17
      src/configparser.y

18
src/configfile.c

@ -218,7 +218,7 @@ void config_reset_config(request_st * const r) {
memcpy(&r->conf, &p->defaults, sizeof(request_config));
}
static int config_burl_normalize_cond (server *srv) {
static void config_burl_normalize_cond (server * const srv) {
buffer * const tb = srv->tmp_buf;
for (uint32_t i = 0; i < srv->config_context->used; ++i) {
data_config * const config =(data_config *)srv->config_context->data[i];
@ -233,12 +233,21 @@ static int config_burl_normalize_cond (server *srv) {
case CONFIG_COND_NOMATCH:
case CONFIG_COND_MATCH:
pcre_keyvalue_burl_normalize_key(&config->string, tb);
if (!data_config_pcre_compile(config)) return 0;
break;
default:
break;
}
}
}
static int config_pcre_keyvalue (server * const srv) {
for (uint32_t i = 0; i < srv->config_context->used; ++i) {
data_config * const dc = (data_config *)srv->config_context->data[i];
if (dc->cond != CONFIG_COND_NOMATCH && dc->cond != CONFIG_COND_MATCH)
continue;
if (!data_config_pcre_compile(dc))
return 0;
}
return 1;
}
@ -857,7 +866,10 @@ static int config_insert_srvconf(server *srv) {
config_deprecate_module_compress(srv);
if (srv->srvconf.http_url_normalize && !config_burl_normalize_cond(srv))
if (srv->srvconf.http_url_normalize)
config_burl_normalize_cond(srv);
if (!config_pcre_keyvalue(srv))
rc = HANDLER_ERROR;
free(srvplug.cvlist);

17
src/configparser.y

@ -310,23 +310,6 @@ configparser_parse_condition(config_t * const ctx, const buffer * const obj_tag,
buffer_copy_buffer(&dc->string, rvalue);
if (ctx->ok) switch(dc->cond) {
case CONFIG_COND_NE:
case CONFIG_COND_EQ:
break;
case CONFIG_COND_NOMATCH:
case CONFIG_COND_MATCH: {
if (!data_config_pcre_compile(dc)) {
ctx->ok = 0;
}
break;
}
default:
fprintf(stderr, "unknown condition for %s\n", dc->comp_key);
ctx->ok = 0;
break;
}
if (ctx->ok)
configparser_push(ctx, dc, 1);
else

Loading…
Cancel
Save