aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_config.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-06-25 14:20:52 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-06-25 14:58:23 +0100
commit78d8e567d2222848b0cce3525bcbb6d0cfbb9300 (patch)
tree75f7405b8f61494ae712bc8e257cdbdac65f4706 /src/lua/lua_config.c
parent31a51f93c00abacf7c0a4f53d47b406731d55f59 (diff)
downloadrspamd-78d8e567d2222848b0cce3525bcbb6d0cfbb9300.tar.gz
rspamd-78d8e567d2222848b0cce3525bcbb6d0cfbb9300.zip
Fix get_all_opts for a case of non-iterable options.
Diffstat (limited to 'src/lua/lua_config.c')
-rw-r--r--src/lua/lua_config.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index ae1f9b0f0..3d3270984 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -429,6 +429,7 @@ lua_config_get_all_opt (lua_State * L)
const gchar *mname;
const ucl_object_t *obj, *cur, *cur_elt;
ucl_object_iter_t it = NULL;
+ gint i;
if (cfg) {
mname = luaL_checkstring (L, 2);
@@ -436,7 +437,8 @@ lua_config_get_all_opt (lua_State * L)
if (mname) {
obj = ucl_obj_get_key (cfg->rcl_obj, mname);
/* Flatten object */
- if (obj != NULL && ucl_object_type (obj) == UCL_OBJECT) {
+ if (obj != NULL && (ucl_object_type (obj) == UCL_OBJECT ||
+ ucl_object_type (obj) == UCL_ARRAY)) {
lua_newtable (L);
it = ucl_object_iterate_new (obj);
@@ -455,6 +457,18 @@ lua_config_get_all_opt (lua_State * L)
return 1;
}
+ else if (obj != NULL) {
+ lua_newtable (L);
+ i = 1;
+
+ LL_FOREACH (obj, cur) {
+ lua_pushnumber (L, i++);
+ ucl_object_push_lua (L, cur, true);
+ lua_settable (L, -3);
+ }
+
+ return 1;
+ }
}
}
lua_pushnil (L);