aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-12-18 14:44:46 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-12-18 16:07:19 +0000
commit10d2f9f5e95b3cea58ee359edfa00667d76facbf (patch)
treeb553444e6aa83f1d42d492cf1d0ae198aaa2f285
parenta683bfc126dd9c4efcb69df4aa2c7f73e5347195 (diff)
downloadrspamd-10d2f9f5e95b3cea58ee359edfa00667d76facbf.tar.gz
rspamd-10d2f9f5e95b3cea58ee359edfa00667d76facbf.zip
[Minor] Relax `parse_text` input arguments to allow both string and text
-rw-r--r--contrib/libucl/lua_ucl.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/contrib/libucl/lua_ucl.c b/contrib/libucl/lua_ucl.c
index f552ce456..988dba355 100644
--- a/contrib/libucl/lua_ucl.c
+++ b/contrib/libucl/lua_ucl.c
@@ -855,7 +855,21 @@ lua_ucl_parser_parse_text (lua_State *L)
int ret = 2;
parser = lua_ucl_parser_get (L, 1);
- t = lua_touserdata (L, 2);
+
+ if (lua_type (L, 2) == LUA_TUSERDATA) {
+ t = lua_touserdata (L, 2);
+ }
+ else {
+ const gchar *s;
+ gsize len;
+ struct _rspamd_lua_text st_t;
+
+ s = lua_tolstring (L, 2, &len);
+ st_t.start = s;
+ st_t.len = len;
+
+ t = &st_t;
+ }
if (lua_type (L, 3) == LUA_TSTRING) {
type = lua_ucl_str_to_parse_type (lua_tostring (L, 3));