diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-04-15 15:52:25 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-04-15 15:52:25 +0100 |
commit | de374366c4872a6edd6a853a3b4dd5d65e2ded11 (patch) | |
tree | 227ba3f3984f74ae55ff02e66b2ea6ac800c90cc /src | |
parent | 6b15d1ed13c0e082d25097f4833e9d533b753678 (diff) | |
download | rspamd-de374366c4872a6edd6a853a3b4dd5d65e2ded11.tar.gz rspamd-de374366c4872a6edd6a853a3b4dd5d65e2ded11.zip |
[Minor] Lua_url: Propagate numeric flags
Diffstat (limited to 'src')
-rw-r--r-- | src/libserver/url.c | 1 | ||||
-rw-r--r-- | src/libserver/url.h | 1 | ||||
-rw-r--r-- | src/lua/lua_url.c | 12 |
3 files changed, 13 insertions, 1 deletions
diff --git a/src/libserver/url.c b/src/libserver/url.c index ad77686b7..a97db640a 100644 --- a/src/libserver/url.c +++ b/src/libserver/url.c @@ -242,6 +242,7 @@ struct rspamd_url_flag_name { {"query", RSPAMD_URL_FLAG_QUERY, -1}, {"content", RSPAMD_URL_FLAG_CONTENT, -1}, {"no_tld", RSPAMD_URL_FLAG_NO_TLD, -1}, + {"truncated", RSPAMD_URL_FLAG_TRUNCATED, -1}, }; diff --git a/src/libserver/url.h b/src/libserver/url.h index 30c5ef0af..11177492d 100644 --- a/src/libserver/url.h +++ b/src/libserver/url.h @@ -40,6 +40,7 @@ enum rspamd_url_flags { RSPAMD_URL_FLAG_NO_TLD = 1u << 22u, RSPAMD_URL_FLAG_TRUNCATED = 1u << 23u, }; +#define RSPAMD_URL_MAX_FLAG_SHIFT (24u) struct rspamd_url_tag { const gchar *data; diff --git a/src/lua/lua_url.c b/src/lua/lua_url.c index c2dade139..f3d64e225 100644 --- a/src/lua/lua_url.c +++ b/src/lua/lua_url.c @@ -1391,13 +1391,23 @@ lua_url_lt (lua_State *L) return 1; } - static gint lua_load_url (lua_State * L) { lua_newtable (L); luaL_register (L, NULL, urllib_f); + /* Push flags */ + lua_createtable (L, 0, RSPAMD_URL_MAX_FLAG_SHIFT); + for (int i = 0; i < RSPAMD_URL_MAX_FLAG_SHIFT; i ++) { + guint flag = 1u << i; + + lua_pushinteger (L, flag); + lua_setfield (L, -2, rspamd_url_flag_to_string (flag)); + } + + lua_setfield (L, -2, "flags"); + return 1; } |