[core] extend server.http-parseopts

"header-strict" => "enable"
  restrict chars permitted in HTTP request headers
    (overrides server.http-parseopt-header-strict)
"host-strict" => "enable"
  restrict chars permitted in HTTP request Host header
    (overrides server.http-parseopt-host-strict)
"host-normalize" => "enable"
  normalize HTTP Host header
    (overrides server.http-parseopt-host-normalize)
personal/stbuehler/fix-fdevent
Glenn Strauss 5 years ago
parent ebd9517639
commit 8c35064583

@ -77,6 +77,18 @@ static int config_http_parseopts (server *srv, array *a) {
for (size_t i = 0; i < a->used; ++i) {
const data_string * const ds = (data_string *)a->data[i];
unsigned short int opt;
int val = 0;
if (buffer_is_equal_string(ds->value, CONST_STR_LEN("enable")))
val = 1;
else if (buffer_is_equal_string(ds->value, CONST_STR_LEN("disable")))
val = 0;
else {
log_error_write(srv, __FILE__, __LINE__, "sbsbs",
"unrecognized value for server.http-parseopts:",
ds->key, "=>", ds->value,
"(expect \"[enable|disable]\")");
rc = 0;
}
if (buffer_is_equal_string(ds->key, CONST_STR_LEN("url-normalize")))
opt = HTTP_PARSEOPT_URL_NORMALIZE;
else if (buffer_is_equal_string(ds->key, CONST_STR_LEN("url-normalize-unreserved")))
@ -97,6 +109,18 @@ static int config_http_parseopts (server *srv, array *a) {
opt = HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REJECT;
else if (buffer_is_equal_string(ds->key, CONST_STR_LEN("url-query-20-plus")))
opt = HTTP_PARSEOPT_URL_NORMALIZE_QUERY_20_PLUS;
else if (buffer_is_equal_string(ds->key, CONST_STR_LEN("header-strict"))) {
srv->srvconf.http_header_strict = val;
continue;
}
else if (buffer_is_equal_string(ds->key, CONST_STR_LEN("host-strict"))) {
srv->srvconf.http_host_strict = val;
continue;
}
else if (buffer_is_equal_string(ds->key, CONST_STR_LEN("host-normalize"))) {
srv->srvconf.http_host_normalize = val;
continue;
}
else {
log_error_write(srv, __FILE__, __LINE__, "sb",
"unrecognized key for server.http-parseopts:",
@ -104,9 +128,9 @@ static int config_http_parseopts (server *srv, array *a) {
rc = 0;
continue;
}
if (buffer_is_equal_string(ds->value, CONST_STR_LEN("enable")))
if (val)
opts |= opt;
else if (buffer_is_equal_string(ds->value, CONST_STR_LEN("disable"))) {
else {
opts &= ~opt;
if (opt == HTTP_PARSEOPT_URL_NORMALIZE) {
opts = 0;
@ -116,13 +140,6 @@ static int config_http_parseopts (server *srv, array *a) {
decode_2f = 0;
}
}
else {
log_error_write(srv, __FILE__, __LINE__, "sbsbs",
"unrecognized value for server.http-parseopts:",
ds->key, "=>", ds->value,
"(expect \"[enable|disable]\")");
rc = 0;
}
}
if (opts != 0) {
opts |= HTTP_PARSEOPT_URL_NORMALIZE;

Loading…
Cancel
Save