From: Vsevolod Stakhov Date: Tue, 15 Jul 2025 10:10:09 +0000 (+0100) Subject: [Rules] Make bitcoin expression to use explicit flags X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F5543%2Fhead;p=thirdparty%2Frspamd.git [Rules] Make bitcoin expression to use explicit flags --- diff --git a/rules/bitcoin.lua b/rules/bitcoin.lua index 6a70721f83..bc8c658057 100644 --- a/rules/bitcoin.lua +++ b/rules/bitcoin.lua @@ -183,8 +183,9 @@ local btc_bleach_re = [[/\b(?:(?:[a-zA-Z]\w+:)|(?:bc1))?[qpzry9x8gf2tvdw0s3jn54k config.regexp['BITCOIN_ADDR'] = { description = 'Message has a valid bitcoin wallet address', - -- Use + operator to ensure that each expression is always evaluated re = string.format('(%s) + (%s) > 0', normal_wallet_re, btc_bleach_re), + -- Disable optimizations for this expression to get all addresses + expression_flags = { 'noopt' }, re_conditions = { [normal_wallet_re] = function(task, txt, s, e) local len = e - s diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c index 85beccd93d..df704b8ed7 100644 --- a/src/plugins/regexp.c +++ b/src/plugins/regexp.c @@ -15,6 +15,10 @@ */ /***MODULE:regexp * rspamd module that implements different regexp rules + * + * For object-based configuration, you can specify: + * - `expression_flags`: array of strings or single string with expression flags + * - `"noopt"`: disable expression optimizations (useful for some SpamAssassin rules) */ @@ -267,6 +271,7 @@ int regexp_module_config(struct rspamd_config *cfg, bool validate) sizeof(struct regexp_module_item)); cur_item->symbol = ucl_object_key(value); cur_item->magic = rspamd_regexp_cb_magic; + cur_item->expression_flags = 0; /* Will be overwritten with parsed flags */ ud.cfg = cfg; ud.conf_obj = value;