diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-08-15 17:45:48 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-08-15 17:45:48 +0100 |
commit | 1e2c58a2e87d9261cecf3e063f57aa3455e5c21f (patch) | |
tree | 41d9173bd0c9ae1b44876b167290bfdb0f7e63f8 /contrib/libucl | |
parent | e33a823ac8d8242fb606b3887c2eab2c3c99c768 (diff) | |
download | rspamd-1e2c58a2e87d9261cecf3e063f57aa3455e5c21f.tar.gz rspamd-1e2c58a2e87d9261cecf3e063f57aa3455e5c21f.zip |
[Minor] Fix import again
Diffstat (limited to 'contrib/libucl')
-rw-r--r-- | contrib/libucl/lua_ucl.c | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/contrib/libucl/lua_ucl.c b/contrib/libucl/lua_ucl.c index dde546538..c2b37b14c 100644 --- a/contrib/libucl/lua_ucl.c +++ b/contrib/libucl/lua_ucl.c @@ -545,27 +545,20 @@ ucl_object_lua_fromelt(lua_State *L, int idx, ucl_string_flags_t flags) obj = ucl_object_typed_new(UCL_NULL); } else { - ucl_object_t *other_elt = lua_ucl_object_get(L, idx); + /* Assume it is a text like object */ + struct rspamd_compat_lua_text *t = lua_touserdata(L, idx); - if (other_elt) { - return ucl_object_ref(other_elt); - } - else { - /* Assume it is a text like object */ - struct rspamd_compat_lua_text *t = lua_touserdata(L, idx); - - if (t) { - if (t->len > 0) { - obj = ucl_object_fromstring_common(t->start, t->len, 0); - } - else { - obj = ucl_object_fromstring_common("", 0, 0); - } + if (t) { + if (t->len > 0) { + obj = ucl_object_fromstring_common(t->start, t->len, 0); + } + else { + obj = ucl_object_fromstring_common("", 0, 0); + } - /* Binary text */ - if (t->flags & (1u << 5u)) { - obj->flags |= UCL_OBJECT_BINARY; - } + /* Binary text */ + if (t->flags & (1u << 5u)) { + obj->flags |= UCL_OBJECT_BINARY; } } } @@ -585,7 +578,22 @@ ucl_object_lua_fromelt(lua_State *L, int idx, ucl_string_flags_t flags) } else { if (type == LUA_TTABLE) { - obj = ucl_object_lua_fromtable(L, idx, flags); + lua_rawgeti(L, idx, 0); + + if (lua_type(L, -1) == LUA_TUSERDATA) { + /* It is a cloaked ucl object */ + obj = lua_ucl_object_get(L, idx); + + if (obj) { + obj = ucl_object_ref(obj); + } + } + + lua_pop(L, 1); + + if (obj == NULL) { + obj = ucl_object_lua_fromtable(L, idx, flags); + } } else if (type == LUA_TFUNCTION) { fd = malloc(sizeof(*fd)); |