[Mailman-Users] Question about ban_list Regular Expression

Mark Sapiro mark at msapiro.net
Fri Nov 21 19:36:06 CET 2008


Barry Finkel wrote:

>I have a question about the ban_list regex.  In a reply on
>Tue, 24 Apr 2007 07:59:28 Mark Sapiro wrote
>
>>  So set Privacy options...->Sender filters->generic_nonmember_action
>>  to Accept so anyone can post and set Privacy options...->Subscription
>>  rules->ban_list to a regex that matches all addresses not in your
>>  domain. E.g.,
>>  
>>  ^.*@(?!example\.com)$
>>  
>>  or if you want to allow sub-domains within your domain
>>  
>>  ^.*@(.*\.)?(?!example\.com)$
>
>If I want subdomains of example.com and anl.gov to be able to
>subscribe (and to ban other domains), is this the correct regex for
>ban_list?
>
>     ^(regex|regex)
>
>i.e.,
>
>     ^(.*@(.*\.)?(?!example\.com)$|.*@(.*\.)?(?!anl\.gov)$)


No.

The first problem is that my original regexps are wrong. I thought I
had tested them, but apparently I hadn't.

The simple domain without subdomains regexp should be

  ^.*@(?!example\.com$)

The domain with subdomains regexp should be

  ^.*@(?!(.*\.)?example\.com$)


That said, the ORing of these regexps as in

  ^(.*@(?!(.*\.)?example\.com$)|.*@(?!(.*\.)?example\.com$))

or even

  ^.*@((?!(.*\.)?example\.com$)|(?!(.*\.)?anl\.gov$))

will always match because these match addresses that don't end with
something and if you OR together two different somethings, every
address doesn't end with at least one of them so every address matches.

You would need something like

  ^.*@(?!(.*\.)?(example\.com|anl\.gov)$)

(and I did test that this time)

-- 
Mark Sapiro <mark at msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan



More information about the Mailman-Users mailing list