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
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
end
end
- if table.maxn(spec_st) > 1 then
+ if #spec_st > 1 then
return spec_st
else
return nil
end
end
end
- if table.maxn(selected) > 1 then
+ if #selected > 1 then
return selected
end
end
end
end
end
- if table.maxn(selected) > 1 then
+ if #selected > 1 then
return selected
end
@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')
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',
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
--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
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)
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
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
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