]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Relax `parse_text` input arguments to allow both string and text
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 18 Dec 2020 14:44:46 +0000 (14:44 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 18 Dec 2020 16:07:19 +0000 (16:07 +0000)
contrib/libucl/lua_ucl.c

index f552ce456b8541666a04ee370a64bd08df61ebea..988dba355b42bc4fa4d72e81beff816117208ed4 100644 (file)
@@ -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));