aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-11-23 20:07:57 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-11-23 20:07:57 +0000
commit08a71f0108cbd92c750924f91d3522364b30e66a (patch)
tree949cea434603adee6d1c82e2170bfb234c942020
parent333733cc7ac808aff5e5ff503c32d9f3fd82afbd (diff)
downloadrspamd-08a71f0108cbd92c750924f91d3522364b30e66a.tar.gz
rspamd-08a71f0108cbd92c750924f91d3522364b30e66a.zip
[Fix] Spamassassin: Preserve 'pcre_only' flag when dealing with regexp replacements
-rw-r--r--src/lua/lua_config.c16
-rw-r--r--src/plugins/lua/spamassassin.lua3
2 files changed, 15 insertions, 4 deletions
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index f3dc414db..836654500 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -3072,20 +3072,30 @@ lua_config_replace_regexp (lua_State *L)
LUA_TRACE_POINT;
struct rspamd_config *cfg = lua_check_config (L, 1);
struct rspamd_lua_regexp *old_re = NULL, *new_re = NULL;
+ gboolean pcre_only = FALSE;
GError *err = NULL;
if (cfg != NULL) {
if (!rspamd_lua_parse_table_arguments (L, 2, &err,
RSPAMD_LUA_PARSE_ARGUMENTS_DEFAULT,
- "*old_re=U{regexp};*new_re=U{regexp}",
- &old_re, &new_re)) {
- msg_err_config ("cannot get parameters list: %e", err);
+ "*old_re=U{regexp};*new_re=U{regexp};pcre_only=B",
+ &old_re, &new_re, &pcre_only)) {
+ gint ret = luaL_error (L, "cannot get parameters list: %s",
+ err ? err->message : "invalid arguments");
if (err) {
g_error_free (err);
}
+
+ return ret;
}
else {
+
+ if (pcre_only) {
+ rspamd_regexp_set_flags (new_re->re,
+ rspamd_regexp_get_flags (new_re->re) | RSPAMD_REGEXP_FLAG_PCRE_ONLY);
+ }
+
rspamd_re_cache_replace (cfg->re_cache, old_re->re, new_re->re);
}
}
diff --git a/src/plugins/lua/spamassassin.lua b/src/plugins/lua/spamassassin.lua
index 691930bb1..2b0e5e44e 100644
--- a/src/plugins/lua/spamassassin.lua
+++ b/src/plugins/lua/spamassassin.lua
@@ -1240,7 +1240,8 @@ local function post_process()
lua_util.debugm(N, rspamd_config, 'replace %1 -> %2', r, nexpr)
rspamd_config:replace_regexp({
old_re = rule['re'],
- new_re = nre
+ new_re = nre,
+ pcre_only = is_pcre_only(rule['symbol']),
})
rule['re'] = nre
rule['re_expr'] = nexpr