Parcourir la source

[Fix] Banish table.maxn from Lua parts

tags/1.3.5
Andrew Lewis il y a 7 ans
Parent
révision
97250eea59

+ 5
- 6
rules/rspamd.classifiers.lua Voir le fichier

@@ -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

+ 1
- 1
src/lua/lua_mimepart.c Voir le fichier

@@ -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')

+ 1
- 1
src/plugins/lua/emails.lua Voir le fichier

@@ -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',

+ 2
- 2
src/plugins/lua/forged_recipients.lua Voir le fichier

@@ -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

+ 4
- 4
src/plugins/lua/hfilter.lua Voir le fichier

@@ -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

+ 1
- 1
src/plugins/lua/ratelimit.lua Voir le fichier

@@ -347,7 +347,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

Chargement…
Annuler
Enregistrer