/* Iterate over table of tables */
for (lua_pushnil (L); lua_next (L, -2);
lua_pop (L, 1)) {
- elt.flags |= RSPAMD_STAT_TOKEN_FLAG_LUA_META;
+ elt.flags = RSPAMD_STAT_TOKEN_FLAG_META|
+ RSPAMD_STAT_TOKEN_FLAG_LUA_META;
if (lua_isnumber (L, -1)) {
gdouble num = lua_tonumber (L, -1);
elt.len = tlen;
g_array_append_val (ar, elt);
}
+ else if (lua_istable (L, -1)) {
+ /* Treat that as unigramms */
+ for (lua_pushnil (L); lua_next (L, -2);
+ lua_pop (L, 1)) {
+ if (lua_isstring (L, -1)) {
+ const gchar *str;
+ gsize tlen;
+
+ str = lua_tolstring (L, -1, &tlen);
+ guint8 *pstr = rspamd_mempool_alloc (
+ task->task_pool,
+ tlen);
+ memcpy (pstr, str, tlen);
+
+ msg_debug_task ("got unigramm "
+ "metatoken string: %*s",
+ (gint) tlen, str);
+ elt.begin = (gchar *) pstr;
+ elt.len = tlen;
+ elt.flags |= RSPAMD_STAT_TOKEN_FLAG_UNIGRAM;
+ g_array_append_val (ar, elt);
+ }
+ }
+ }
}
}
}