aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libucl
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2024-08-13 15:07:06 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2024-08-13 15:07:06 +0100
commit9ec9f02eb9fa2faf60873547a14b758240289398 (patch)
treea4a453f503dd347b0a500554f973c19d8188718a /contrib/libucl
parent82057d4e93a871979186d0f3c117def5aa300783 (diff)
downloadrspamd-9ec9f02eb9fa2faf60873547a14b758240289398.tar.gz
rspamd-9ec9f02eb9fa2faf60873547a14b758240289398.zip
[Fix] Make tostring in UCL a bit less brain-damaged
Diffstat (limited to 'contrib/libucl')
-rw-r--r--contrib/libucl/lua_ucl.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/contrib/libucl/lua_ucl.c b/contrib/libucl/lua_ucl.c
index 3e3a06605..79c658615 100644
--- a/contrib/libucl/lua_ucl.c
+++ b/contrib/libucl/lua_ucl.c
@@ -1146,8 +1146,9 @@ lua_ucl_object_tostring(lua_State *L)
enum ucl_emitter format = UCL_EMIT_JSON_COMPACT;
obj = lua_ucl_object_get(L, 1);
+ int type = ucl_object_type(obj);
- if (obj) {
+ if (type == UCL_ARRAY || type == UCL_OBJECT) {
if (lua_gettop(L) > 1) {
if (lua_type(L, 2) == LUA_TSTRING) {
const char *strtype = lua_tostring(L, 2);
@@ -1158,9 +1159,12 @@ lua_ucl_object_tostring(lua_State *L)
return lua_ucl_to_string(L, obj, format);
}
- else {
+ else if (type == UCL_NULL) {
lua_pushnil(L);
}
+ else {
+ ucl_object_lua_push_scalar(L, obj, 0);
+ }
return 1;
}