diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-10-15 11:31:35 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-10-15 11:31:35 +0100 |
commit | afdd86ad9be24f1b4843b9f4d990b13590d8a4a6 (patch) | |
tree | 080979ca95ff53c5d9948b1e787194cb4f7bd697 /contrib | |
parent | 93bef053f18055a217a4ad532b44592b6608f589 (diff) | |
download | rspamd-afdd86ad9be24f1b4843b9f4d990b13590d8a4a6.tar.gz rspamd-afdd86ad9be24f1b4843b9f4d990b13590d8a4a6.zip |
[Minor] Allow ucl emitters to output rspamd_text
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/libucl/lua_ucl.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/contrib/libucl/lua_ucl.c b/contrib/libucl/lua_ucl.c index 4e5eb9452..f2d4f24d6 100644 --- a/contrib/libucl/lua_ucl.c +++ b/contrib/libucl/lua_ucl.c @@ -82,6 +82,11 @@ static ucl_object_t* ucl_object_lua_fromelt (lua_State *L, int idx, ucl_string_f static void *ucl_null; +struct _rspamd_lua_text { + const char *start; + unsigned int len; + unsigned int flags; +}; enum lua_ucl_push_flags { LUA_UCL_DEFAULT_FLAGS = 0, @@ -501,6 +506,14 @@ ucl_object_lua_fromelt (lua_State *L, int idx, ucl_string_flags_t flags) if (lua_topointer (L, idx) == ucl_null) { obj = ucl_object_typed_new (UCL_NULL); } + else { + /* Assume it is a text like object */ + struct _rspamd_lua_text *t = lua_touserdata (L, idx); + + if (t) { + obj = ucl_object_fromstring_common(t->start, t->len, 0); + } + } break; case LUA_TTABLE: case LUA_TFUNCTION: @@ -834,12 +847,6 @@ lua_ucl_parser_parse_string (lua_State *L) return ret; } -struct _rspamd_lua_text { - const char *start; - unsigned int len; - unsigned int flags; -}; - /*** * @method parser:parse_text(input) * Parse UCL object from text object (Rspamd specific). @@ -1440,10 +1447,11 @@ lua_ucl_to_format (lua_State *L) format = UCL_EMIT_YAML; } else if (strcasecmp (strtype, "config") == 0 || - strcasecmp (strtype, "ucl") == 0) { + strcasecmp (strtype, "ucl") == 0) { format = UCL_EMIT_CONFIG; } - else if (strcasecmp (strtype, "msgpack") == 0) { + else if (strcasecmp (strtype, "msgpack") == 0 || + strcasecmp (strtype, "messagepack") == 0) { format = UCL_EMIT_MSGPACK; } } |