On Fri, Apr 30, 2021 at 10:58:09PM +0300, Henrik K wrote: > On Fri, Apr 30, 2021 at 09:36:00PM +0300, Henrik K wrote: > > On Fri, Apr 30, 2021 at 11:30:37AM -0700, John Hardin wrote: > > > > > > Generating a RE fragment that would match on any of the extracted to/cc > > > header email addresses would probably be fairly easy as part of this. But > > > how would we incorporate that fragment in rules? > > > > Probably impossible to implement for normal regex rules, because they are > > all compiled at start.. it would require modifying them on the fly by > > replacing some tag or so. > > > > Designing a plugin for it would be much easier and more versatile.. > > Ok thinking about it more, Replacetags already has the base functionality.. > could extend it a bit more to replace static metadata like To addresses, > which is already parsed and known before any rules run. I'll give it a > try.
Yeah it gets too complicated. The compiled regexes live for all the duration of the process, which can process many messages. If you change the regex in later than in config parse stage, then it would require some new logic to always restore the original regex when a new message is processed, and yet again replace it. Doing all that for a some static header field data seems very unflexible too. What if you want to match some other string, maybe something from the body text? It seems a better solution would be making regex rules able to capture something, and then you have some rules which would have dependency on that hitting and use the captured variable. The need for "rules dependency/chaining" is also already a feature we need, mentioned for example in https://bz.apache.org/SpamAssassin/show_bug.cgi?id=6855 Wouldn't be much of a more stretch to add some capture variables in the mix.
