aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2016-09-01 10:22:50 +0200
committerAndrew Lewis <nerf@judo.za.org>2016-09-01 10:22:50 +0200
commit47fb93233a3f9ee2ca1c49d802113a392b660df4 (patch)
treeb95dc29ef9ddadf6ad1173ef25e9e4533feb3719
parenteb7db9325e5460cd9980fcf24805aaa0c0659668 (diff)
downloadrspamd-47fb93233a3f9ee2ca1c49d802113a392b660df4.tar.gz
rspamd-47fb93233a3f9ee2ca1c49d802113a392b660df4.zip
[Fix] Banish table.maxn from Lua parts
-rw-r--r--rules/rspamd.classifiers.lua11
-rw-r--r--src/lua/lua_mimepart.c2
-rw-r--r--src/plugins/lua/emails.lua2
-rw-r--r--src/plugins/lua/forged_recipients.lua4
-rw-r--r--src/plugins/lua/hfilter.lua8
-rw-r--r--src/plugins/lua/ratelimit.lua2
6 files changed, 14 insertions, 15 deletions
diff --git a/rules/rspamd.classifiers.lua b/rules/rspamd.classifiers.lua
index c509ef23d..77f506ee8 100644
--- a/rules/rspamd.classifiers.lua
+++ b/rules/rspamd.classifiers.lua
@@ -34,8 +34,7 @@ local function get_specific_statfiles(classifier, task)
local st_many = classifier:get_statfile_by_label(many_recipients_label)
if st_many then
rcpt = task:get_recipients(2)
- if rcpt and table.maxn(rcpt) > 5 then
- print(table.maxn(rcpt))
+ if rcpt and #rcpt > 5 then
table.foreach(st_many, function(i,v) table.insert(spec_st,v) end)
end
end
@@ -43,7 +42,7 @@ local function get_specific_statfiles(classifier, task)
local st_undisc = classifier:get_statfile_by_label(undisclosed_recipients_label)
if st_undisc then
rcpt = task:get_recipients(2)
- if rcpt and table.maxn(rcpt) == 0 then
+ if rcpt and #rcpt == 0 then
table.foreach(st_undisc, function(i,v) table.insert(spec_st,v) end)
end
end
@@ -64,7 +63,7 @@ local function get_specific_statfiles(classifier, task)
end
end
- if table.maxn(spec_st) > 1 then
+ if #spec_st > 1 then
return spec_st
else
return nil
@@ -109,7 +108,7 @@ classifiers['bayes'] = function(classifier, task, is_learn, is_spam)
end
end
end
- if table.maxn(selected) > 1 then
+ if #selected > 1 then
return selected
end
end
@@ -125,7 +124,7 @@ classifiers['bayes'] = function(classifier, task, is_learn, is_spam)
end
end
end
- if table.maxn(selected) > 1 then
+ if #selected > 1 then
return selected
end
diff --git a/src/lua/lua_mimepart.c b/src/lua/lua_mimepart.c
index b8f7d8f85..d519cccbe 100644
--- a/src/lua/lua_mimepart.c
+++ b/src/lua/lua_mimepart.c
@@ -151,7 +151,7 @@ static const struct luaL_reg textpartlib_m[] = {
@example
rspamd_config.MISSING_CONTENT_TYPE = function(task)
local parts = task:get_parts()
- if parts and table.maxn(parts) > 1 then
+ if parts and #parts > 1 then
-- We have more than one part
for _,p in ipairs(parts) do
local ct = p:get_header('Content-Type')
diff --git a/src/plugins/lua/emails.lua b/src/plugins/lua/emails.lua
index 862d82725..9d9a54d03 100644
--- a/src/plugins/lua/emails.lua
+++ b/src/plugins/lua/emails.lua
@@ -107,7 +107,7 @@ if opts and type(opts) == 'table' then
end
end
-if table.maxn(rules) > 0 then
+if #rules > 0 then
-- add fake symbol to check all maps inside a single callback
local id = rspamd_config:register_symbol({
type = 'callback',
diff --git a/src/plugins/lua/forged_recipients.lua b/src/plugins/lua/forged_recipients.lua
index a9347a685..957491a56 100644
--- a/src/plugins/lua/forged_recipients.lua
+++ b/src/plugins/lua/forged_recipients.lua
@@ -30,9 +30,9 @@ local function check_forged_headers(task)
local mime_rcpt = task:get_recipients(2)
local count = 0
if mime_rcpt then
- count = table.maxn(mime_rcpt)
+ count = #mime_rcpt
end
- if count > 0 and count < table.maxn(smtp_rcpt) then
+ if count > 0 and count < #smtp_rcpt then
task:insert_result(symbol_rcpt, 1)
elseif count > 0 then
-- Find pair for each smtp recipient recipient in To or Cc headers
diff --git a/src/plugins/lua/hfilter.lua b/src/plugins/lua/hfilter.lua
index 7db6eab5f..34a679641 100644
--- a/src/plugins/lua/hfilter.lua
+++ b/src/plugins/lua/hfilter.lua
@@ -395,7 +395,7 @@ local function hfilter(task)
--FROM host check
for _,fr in ipairs(from) do
local fr_split = rspamd_str_split(fr['addr'], '@')
- if table.maxn(fr_split) == 2 then
+ if #fr_split == 2 then
check_host(task, fr_split[2], 'FROMHOST', '', '')
if fr_split[1] == 'postmaster' then
frombounce = true
@@ -414,7 +414,7 @@ local function hfilter(task)
if config['rcpt_enabled'] then
local rcpt = task:get_recipients()
if rcpt then
- local count_rcpt = table.maxn(rcpt)
+ local count_rcpt = #rcpt
if frombounce then
if count_rcpt > 1 then
task:insert_result('HFILTER_RCPT_BOUNCEMOREONE', 1.00)
@@ -428,7 +428,7 @@ local function hfilter(task)
local message_id = task:get_message_id()
if message_id then
local mid_split = rspamd_str_split(message_id, '@')
- if table.maxn(mid_split) == 2 and not string.find(mid_split[2], 'local') then
+ if #mid_split == 2 and not string.find(mid_split[2], 'local') then
check_host(task, mid_split[2], 'MID')
end
end
@@ -509,6 +509,6 @@ if config['url_enabled'] then
end
--dumper(symbols_enabled)
-if table.maxn(symbols_enabled) > 0 then
+if #symbols_enabled > 0 then
rspamd_config:register_symbols(hfilter, 1.0, "HFILTER", symbols_enabled);
end
diff --git a/src/plugins/lua/ratelimit.lua b/src/plugins/lua/ratelimit.lua
index b80a122f1..d8e53d4d0 100644
--- a/src/plugins/lua/ratelimit.lua
+++ b/src/plugins/lua/ratelimit.lua
@@ -414,7 +414,7 @@ local function parse_limit(str)
limit[2] = tonumber(rate)
end
- if table.maxn(params) ~= 3 then
+ if #params ~= 3 then
rspamd_logger.errx(rspamd_config, 'invalid limit definition: ' .. str)
return
end