Yahoo Groups archive

Milter-greylist

Index last updated: 2026-04-28 23:32 UTC

Message

Re: [milter-greylist] Blacklisting syntax

2006-08-08 by Matt Kettler

Emmanuel Dreyfus wrote:
> On Tue, Aug 08, 2006 at 07:18:57AM -0500, Jack L. Stone wrote:
>> list "known spammers" rcpt { /.*@.../ /.*@.../ /bad1@*/
>> /bad2@*/ }
> 
> IMO, you want /.*@example1\.com/ and /bad1@.*/
> 

Side note:

why /.*@example\.com/ instead of /@example\.com/ ?

In general, because regexes match sub-strings, any wild-cards at the beginning
or end of a regex are redundant and reduce efficiency.

/foo/ is equivalent to /.*foo.*/, but the later takes longer to run and uses
more memory. Both will match "foo" "foobar"  "somefoo" and "somefoobar".


You can abuse perl's regex debugger to compare the two. Admittedly,
milter-greylist doesn't use perl's regex engine, but it's a quick-and-easy tool
to show what at least one regex compiler will do with it in a straight-forward
implementation. (The perl regex optimizer might remove some of this later if you
did it in perl, but I doubt the basic POSIX regex library does such things).

Note the difference in the "size" and the number of bytes for offset annotations.

-------------------------------
perl -Mre=debug -e  "/foo/"
Freeing REx: `","'
Compiling REx `foo'
size 3 Got 28 bytes for offset annotations.
first at 1
rarest char f at 0
   1: EXACT <foo>(3)
   3: END(0)
anchored `foo' at 0 (checking anchored isall) minlen 3
Offsets: [3]
        1[3] 0[0] 4[0]
Omitting $` $& $' support.

-------------------------------
$perl -Mre=debug -e  "/.*foo.*/"
Freeing REx: `","'
Compiling REx `.*foo.*'
size 7 Got 60 bytes for offset annotations.
first at 2
rarest char f at 0
   1: STAR(3)
   2:   REG_ANY(0)
   3: EXACT <foo>(5)
   5: STAR(7)
   6:   REG_ANY(0)
   7: END(0)
floating `foo' at 0..2147483647 (checking floating) anchored(MBOL) implicit minlen 3

Offsets: [7]
        2[1] 1[1] 3[3] 0[0] 7[1] 6[1] 8[0]
Omitting $` $& $' support.
-------------------------------

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.