-- Minimum score to treat symbols as meta
local meta_score_alpha = 0.5
+-- Maximum size of regexp checked
+local match_limit = 0
+
local function split(str, delim)
local result = {}
if cur_rule['re'] and cur_rule['symbol'] and
(cur_rule['header'] or cur_rule['function']) then
valid_rule = true
+ cur_rule['re']:set_limit(match_limit)
end
else
-- Maybe we know the function and can convert it
cur_rule['re_expr'] = words_to_re(words, 2)
cur_rule['re'] = rspamd_regexp.create_cached(cur_rule['re_expr'])
cur_rule['raw'] = true
- if cur_rule['re'] and cur_rule['symbol'] then valid_rule = true end
+
+ if cur_rule['re'] and cur_rule['symbol'] then
+ valid_rule = true
+ cur_rule['re']:set_limit(match_limit)
+ end
elseif words[1] == "rawbody" or words[1] == "full" and slash then
-- body SYMBOL /regexp/
if valid_rule then
cur_rule['symbol'] = words[2]
cur_rule['re_expr'] = words_to_re(words, 2)
cur_rule['re'] = rspamd_regexp.create_cached(cur_rule['re_expr'])
- if cur_rule['re'] and cur_rule['symbol'] then valid_rule = true end
+ if cur_rule['re'] and cur_rule['symbol'] then
+ valid_rule = true
+ cur_rule['re']:set_limit(match_limit)
+ end
elseif words[1] == "uri" then
-- uri SYMBOL /regexp/
if valid_rule then
cur_rule['symbol'] = words[2]
cur_rule['re_expr'] = words_to_re(words, 2)
cur_rule['re'] = rspamd_regexp.create_cached(cur_rule['re_expr'])
- if cur_rule['re'] and cur_rule['symbol'] then valid_rule = true end
+ if cur_rule['re'] and cur_rule['symbol'] then
+ valid_rule = true
+ cur_rule['re']:set_limit(match_limit)
+ end
elseif words[1] == "meta" then
-- meta SYMBOL expression
if valid_rule then
for k,fn in pairs(section) do
if k == 'alpha' and type(fn) == 'number' then
meta_score_alpha = fn
- end
- f = io.open(fn, "r")
- if f then
- process_sa_conf(f)
+ elseif k == 'match_limit' and type(fn) == 'number' then
+ match_limit = fn
+ else
+ f = io.open(fn, "r")
+ if f then
+ process_sa_conf(f)
+ end
end
end
end
rspamd_logger.debugx('replace %1 -> %2', r, nexpr)
rule['re'] = nre
rule['re_expr'] = nexpr
+ nre:set_limit(match_limit)
end
end
end