Browse Source

[Fix] Banish table.maxn from Lua parts

tags/1.3.5
Andrew Lewis 7 years ago
parent
commit
97250eea59

+ 5
- 6
rules/rspamd.classifiers.lua View File

local st_many = classifier:get_statfile_by_label(many_recipients_label) local st_many = classifier:get_statfile_by_label(many_recipients_label)
if st_many then if st_many then
rcpt = task:get_recipients(2) 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) table.foreach(st_many, function(i,v) table.insert(spec_st,v) end)
end end
end end
local st_undisc = classifier:get_statfile_by_label(undisclosed_recipients_label) local st_undisc = classifier:get_statfile_by_label(undisclosed_recipients_label)
if st_undisc then if st_undisc then
rcpt = task:get_recipients(2) 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) table.foreach(st_undisc, function(i,v) table.insert(spec_st,v) end)
end end
end end
end end
end end
if table.maxn(spec_st) > 1 then
if #spec_st > 1 then
return spec_st return spec_st
else else
return nil return nil
end end
end end
end end
if table.maxn(selected) > 1 then
if #selected > 1 then
return selected return selected
end end
end end
end end
end end
end end
if table.maxn(selected) > 1 then
if #selected > 1 then
return selected return selected
end end

+ 1
- 1
src/lua/lua_mimepart.c View File

@example @example
rspamd_config.MISSING_CONTENT_TYPE = function(task) rspamd_config.MISSING_CONTENT_TYPE = function(task)
local parts = task:get_parts() 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 -- We have more than one part
for _,p in ipairs(parts) do for _,p in ipairs(parts) do
local ct = p:get_header('Content-Type') local ct = p:get_header('Content-Type')

+ 1
- 1
src/plugins/lua/emails.lua View File

end end
end end


if table.maxn(rules) > 0 then
if #rules > 0 then
-- add fake symbol to check all maps inside a single callback -- add fake symbol to check all maps inside a single callback
local id = rspamd_config:register_symbol({ local id = rspamd_config:register_symbol({
type = 'callback', type = 'callback',

+ 2
- 2
src/plugins/lua/forged_recipients.lua View File

local mime_rcpt = task:get_recipients(2) local mime_rcpt = task:get_recipients(2)
local count = 0 local count = 0
if mime_rcpt then if mime_rcpt then
count = table.maxn(mime_rcpt)
count = #mime_rcpt
end 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) task:insert_result(symbol_rcpt, 1)
elseif count > 0 then elseif count > 0 then
-- Find pair for each smtp recipient recipient in To or Cc headers -- Find pair for each smtp recipient recipient in To or Cc headers

+ 4
- 4
src/plugins/lua/hfilter.lua View File

--FROM host check --FROM host check
for _,fr in ipairs(from) do for _,fr in ipairs(from) do
local fr_split = rspamd_str_split(fr['addr'], '@') 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', '', '') check_host(task, fr_split[2], 'FROMHOST', '', '')
if fr_split[1] == 'postmaster' then if fr_split[1] == 'postmaster' then
frombounce = true frombounce = true
if config['rcpt_enabled'] then if config['rcpt_enabled'] then
local rcpt = task:get_recipients() local rcpt = task:get_recipients()
if rcpt then if rcpt then
local count_rcpt = table.maxn(rcpt)
local count_rcpt = #rcpt
if frombounce then if frombounce then
if count_rcpt > 1 then if count_rcpt > 1 then
task:insert_result('HFILTER_RCPT_BOUNCEMOREONE', 1.00) task:insert_result('HFILTER_RCPT_BOUNCEMOREONE', 1.00)
local message_id = task:get_message_id() local message_id = task:get_message_id()
if message_id then if message_id then
local mid_split = rspamd_str_split(message_id, '@') 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') check_host(task, mid_split[2], 'MID')
end end
end end
end end


--dumper(symbols_enabled) --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); rspamd_config:register_symbols(hfilter, 1.0, "HFILTER", symbols_enabled);
end end

+ 1
- 1
src/plugins/lua/ratelimit.lua View File

limit[2] = tonumber(rate) limit[2] = tonumber(rate)
end end


if table.maxn(params) ~= 3 then
if #params ~= 3 then
rspamd_logger.errx(rspamd_config, 'invalid limit definition: ' .. str) rspamd_logger.errx(rspamd_config, 'invalid limit definition: ' .. str)
return return
end end

Loading…
Cancel
Save