From 0e21da4e3833d702db12e4129926d7918a1ac527 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 28 Jul 2020 15:47:51 +0100 Subject: [Project] Add `L` flag for regexps to save start of the match in Hyperscan --- src/libmime/mime_expressions.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/libmime') diff --git a/src/libmime/mime_expressions.c b/src/libmime/mime_expressions.c index aaefd24b3..0caa324cc 100644 --- a/src/libmime/mime_expressions.c +++ b/src/libmime/mime_expressions.c @@ -372,6 +372,8 @@ rspamd_mime_expr_parse_regexp_atom (rspamd_mempool_t * pool, const gchar *line, case 'u': case 'O': case 'r': + case 'L': + /* Handled by rspamd_regexp_t */ g_string_append_c (re_flags, *p); p++; break; @@ -813,6 +815,10 @@ set: goto err; } else { + const ucl_object_t *re_conditions = ucl_object_lookup (real_ud->conf_obj, + "re_conditions"); + gint lua_cbref = -1; + /* Check regexp condition */ if (real_ud->conf_obj == NULL) { g_set_error (err, rspamd_mime_expr_quark(), 300, @@ -821,10 +827,6 @@ set: goto err; } - const ucl_object_t *re_conditions = ucl_object_lookup (real_ud->conf_obj, - "re_conditions"); - gint lua_cbref = -1; - if (re_conditions != NULL) { if (ucl_object_type (re_conditions) != UCL_OBJECT) { g_set_error (err, rspamd_mime_expr_quark(), 320, @@ -851,6 +853,10 @@ set: } } + if (lua_cbref != -1) { + msg_info_config ("added condition for regexp %s", mime_atom->str); + } + /* Register new item in the cache */ if (mime_atom->d.re->type == RSPAMD_RE_HEADER || mime_atom->d.re->type == RSPAMD_RE_RAWHEADER || -- cgit v1.2.3