aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-05-18 16:33:14 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-05-18 16:33:14 +0100
commit3540ae213ae6be23c5b9a4d8ff758833604716c9 (patch)
tree8c1a80eb7750c5b55ef6557851ed7c780b763917 /src/lua
parentd5390649413a38b4ccc37e9e657d7b5b5f040796 (diff)
downloadrspamd-3540ae213ae6be23c5b9a4d8ff758833604716c9.tar.gz
rspamd-3540ae213ae6be23c5b9a4d8ff758833604716c9.zip
[Fix] Fix get_urls table invocation
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_url.c59
1 files changed, 36 insertions, 23 deletions
diff --git a/src/lua/lua_url.c b/src/lua/lua_url.c
index f07f94bbd..b49146292 100644
--- a/src/lua/lua_url.c
+++ b/src/lua/lua_url.c
@@ -964,6 +964,7 @@ lua_url_cbdata_fill (lua_State *L,
gint pos_arg_type = lua_type (L, pos);
guint flags_mask = default_flags;
+ gboolean seen_flags = FALSE, seen_protocols = FALSE;
if (pos_arg_type == LUA_TBOOLEAN) {
protocols_mask = default_protocols;
@@ -977,7 +978,9 @@ lua_url_cbdata_fill (lua_State *L,
lua_getfield (L, pos, "flags");
if (lua_istable (L, -1)) {
- for (lua_pushnil (L); lua_next (L, pos); lua_pop (L, 1)) {
+ gint top = lua_gettop (L);
+
+ for (lua_pushnil (L); lua_next (L, top); lua_pop (L, 1)) {
int nmask = 0;
const gchar *fname = lua_tostring (L, -1);
@@ -990,6 +993,7 @@ lua_url_cbdata_fill (lua_State *L,
return FALSE;
}
}
+ seen_flags = TRUE;
}
else {
flags_mask |= default_flags;
@@ -998,7 +1002,9 @@ lua_url_cbdata_fill (lua_State *L,
lua_getfield (L, pos, "protocols");
if (lua_istable (L, -1)) {
- for (lua_pushnil (L); lua_next (L, pos); lua_pop (L, 1)) {
+ gint top = lua_gettop (L);
+
+ for (lua_pushnil (L); lua_next (L, top); lua_pop (L, 1)) {
int nmask;
const gchar *pname = lua_tostring (L, -1);
@@ -1012,47 +1018,54 @@ lua_url_cbdata_fill (lua_State *L,
return FALSE;
}
}
+ seen_protocols = TRUE;
}
else {
protocols_mask = default_protocols;
}
lua_pop (L, 1);
- lua_getfield (L, pos, "emails");
- if (lua_isboolean (L, -1)) {
- if (lua_toboolean (L, -1)) {
- protocols_mask |= PROTOCOL_MAILTO;
+ if (!seen_protocols) {
+ lua_getfield (L, pos, "emails");
+ if (lua_isboolean (L, -1)) {
+ if (lua_toboolean (L, -1)) {
+ protocols_mask |= PROTOCOL_MAILTO;
+ }
}
+ lua_pop (L, 1);
}
- lua_pop (L, 1);
- lua_getfield (L, pos, "images");
- if (lua_isboolean (L, -1)) {
- if (lua_toboolean (L, -1)) {
- flags_mask |= RSPAMD_URL_FLAG_IMAGE;
+ if (!seen_flags) {
+ lua_getfield (L, pos, "images");
+ if (lua_isboolean (L, -1)) {
+ if (lua_toboolean (L, -1)) {
+ flags_mask |= RSPAMD_URL_FLAG_IMAGE;
+ }
+ else {
+ flags_mask &= ~RSPAMD_URL_FLAG_IMAGE;
+ }
}
else {
flags_mask &= ~RSPAMD_URL_FLAG_IMAGE;
}
+ lua_pop (L, 1);
}
- else {
- flags_mask &= ~RSPAMD_URL_FLAG_IMAGE;
- }
- lua_pop (L, 1);
- lua_getfield (L, pos, "content");
- if (lua_isboolean (L, -1)) {
- if (lua_toboolean (L, -1)) {
- flags_mask |= RSPAMD_URL_FLAG_CONTENT;
+ if (!seen_flags) {
+ lua_getfield (L, pos, "content");
+ if (lua_isboolean (L, -1)) {
+ if (lua_toboolean (L, -1)) {
+ flags_mask |= RSPAMD_URL_FLAG_CONTENT;
+ }
+ else {
+ flags_mask &= ~RSPAMD_URL_FLAG_CONTENT;
+ }
}
else {
flags_mask &= ~RSPAMD_URL_FLAG_CONTENT;
}
+ lua_pop (L, 1);
}
- else {
- flags_mask &= ~RSPAMD_URL_FLAG_CONTENT;
- }
- lua_pop (L, 1);
lua_getfield (L, pos, "max_urls");
if (lua_isnumber (L, -1)) {