return s:match "^%s*(.-)%s*$"
end
+local ffi
+if type(jit) == 'table' then
+ ffi = require("ffi")
+ ffi.cdef[[
+ int rspamd_re_cache_type_from_string (const char *str);
+ int rspamd_re_cache_process_ffi (void *ptask,
+ void *pre,
+ int type,
+ const char *type_data,
+ int is_strong);
+]]
+end
+
+local function process_regexp_opt(re, task, re_type, header, strong)
+ if type(jit) == 'table' then
+ -- Use ffi call
+ local itype = ffi.C.rspamd_re_cache_type_from_string(re_type)
+
+ if not strong then
+ strong = 0
+ else
+ string = 1
+ end
+ local iret = ffi.C.rspamd_re_cache_process_ffi (task, re, itype, header, strong)
+
+ return tonumber(iret)
+ else
+ return task:process_regexp(re, re_type, header, strong)
+ end
+end
+
local function is_pcre_only(name)
if pcre_only_regexps[name] then
return true
return 0
end
- return task:process_regexp(re, 'allheader')
+ return process_regexp_opt(re, task, 'allheader')
end
else
local args = split(h, '[^:]+')
return 0
end
- local ret = task:process_regexp(r['re'], t, h['header'], h['strong'])
+ local ret = process_regexp_opt(r.re, task, t, h.header, h.strong)
if r['not'] then
if ret ~= 0 then
local t = 'mime'
if r['raw'] then t = 'rawmime' end
- return task:process_regexp(r['re'], t)
+ return process_regexp_opt(r.re, task, t)
end
if r['score'] then
local real_score = r['score'] * calculate_score(k, r)
local t = r['type']
- local ret = task:process_regexp(r['re'], t)
+ local ret = process_regexp_opt(r.re, task, t)
return ret
end
if r['score'] then
return 0
end
- return task:process_regexp(r['re'], 'url')
+ return process_regexp_opt(r.re, task, 'url')
end
if r['score'] then
local real_score = r['score'] * calculate_score(k, r)