]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Rules] Make bitcoin expression to use explicit flags 5543/head
authorVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 15 Jul 2025 10:10:09 +0000 (11:10 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 15 Jul 2025 10:10:09 +0000 (11:10 +0100)
rules/bitcoin.lua
src/plugins/regexp.c

index 6a70721f83070caed226f3b5861ebbbfff441a1c..bc8c658057f63d753b4e7598482d790a455bd903 100644 (file)
@@ -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
index 85beccd93d82131a7c9a994750eb8e91d7d6077a..df704b8ed760fa33b2b60c6c226d4bf66c85bfc8 100644 (file)
  */
 /***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;