diff options
author | Glenn Strauss <gstrauss@gluelogic.com> | 2019-12-07 19:15:55 -0500 |
---|---|---|
committer | Glenn Strauss <gstrauss@gluelogic.com> | 2020-07-08 19:54:28 -0400 |
commit | 03b4c993d206221b02cda31e9d25cf2b4bc0813e (patch) | |
tree | 216e0821e67ea43926cad8ceb401a51ae08c9849 /src/configfile-glue.c | |
parent | 81c9d0acf100d8e89d8d688d29beb1e5bb8d873a (diff) | |
download | lighttpd-git-03b4c993d206221b02cda31e9d25cf2b4bc0813e.tar.gz |
[multiple] generic config array type checking
Diffstat (limited to 'src/configfile-glue.c')
-rw-r--r-- | src/configfile-glue.c | 56 |
1 files changed, 51 insertions, 5 deletions
diff --git a/src/configfile-glue.c b/src/configfile-glue.c index 6290ec7b..98500ab1 100644 --- a/src/configfile-glue.c +++ b/src/configfile-glue.c @@ -50,19 +50,65 @@ int config_plugin_values_init_block(server * const srv, const array * const ca, switch (cpk[i].ktype) { case T_CONFIG_ARRAY: + case T_CONFIG_ARRAY_KVANY: + case T_CONFIG_ARRAY_KVARRAY: + case T_CONFIG_ARRAY_KVSTRING: + case T_CONFIG_ARRAY_VLIST: if (du->type == TYPE_ARRAY) { cpv->v.a = &((const data_array *)du)->value; - /* future: might provide modifiers to perform one of - * array_is_{vlist,kvany,kvarray,kvstring}() tests - * and provide generic error message if mismatch */ } else { log_error(srv->errh, __FILE__, __LINE__, - "%s should have been an array of strings like " - "... = ( \"...\" )", cpk[i].k); + "%s should have been a list like " + "%s = ( \"...\" )", cpk[i].k, cpk[i].k); rc = 0; continue; } + switch (cpk[i].ktype) { + case T_CONFIG_ARRAY_KVANY: + if (!array_is_kvany(cpv->v.a)) { + log_error(srv->errh, __FILE__, __LINE__, + "%s should have been a list of key => values like " + "%s = ( \"...\" => \"...\", \"...\" => \"...\" )", + cpk[i].k, cpk[i].k); + rc = 0; + continue; + } + break; + case T_CONFIG_ARRAY_KVARRAY: + if (!array_is_kvarray(cpv->v.a)) { + log_error(srv->errh, __FILE__, __LINE__, + "%s should have been a list of key => list like " + "%s = ( \"...\" => ( \"...\" => \"...\" ) )", + cpk[i].k, cpk[i].k); + rc = 0; + continue; + } + break; + case T_CONFIG_ARRAY_KVSTRING: + if (!array_is_kvstring(cpv->v.a)) { + log_error(srv->errh, __FILE__, __LINE__, + "%s should have been a list of key => string values like " + "%s = ( \"...\" => \"...\", \"...\" => \"...\" )", + cpk[i].k, cpk[i].k); + rc = 0; + continue; + } + break; + case T_CONFIG_ARRAY_VLIST: + if (!array_is_vlist(cpv->v.a)) { + log_error(srv->errh, __FILE__, __LINE__, + "%s should have been a list of string values like " + "%s = ( \"...\", \"...\" )", + cpk[i].k, cpk[i].k); + rc = 0; + continue; + } + break; + /*case T_CONFIG_ARRAY:*/ + default: + break; + } break; case T_CONFIG_STRING: if (du->type == TYPE_STRING) { |