Re: [Exim] wildlsearch

Top Page
Delete this message
Reply to this message
Author: Philip Hazel
Date:  
To: gARetH baBB
CC: exim-users
Subject: Re: [Exim] wildlsearch
On Mon, 21 Jul 2003, gARetH baBB wrote:

> And in .bouncelist I have things like:
>
> ^.*@(.*\.|)(cn|tw|es)$


<aside>
The most efficient way to write a regex that means "ends with X" is

^.*(?<=X)

provided that each alternative in X is of fixed length (as yours is).
Thus:

^.*(?<=\.(cn|tw|es))

The .* moves to the end of the subject; the lookbehind then does just
one test for each alternative. No backtracking is involved. Written the
"natural" way that you wrote it, there will be a lot of backtracking as
it tries all the different possibilities for matching the initial .*
item and the other .* item as well.

Note there is no need for a trailing $.
</aside>

> I wanted to extend this to HELO, so I've ended up with:
>
> bounce_helo:
> driver = redirect
> check_local_user
> allow_defer
> allow_fail
> hide_child_in_errmsg
> data = :fail: Rejected
> condition = ${if exists {$home/.bouncehelo} {${lookup {$sender_helo_name} wildlsearch{$home/.bouncehelo}{yes}} }}
>
> This fails on regex like the example for senders because of the trailing $.


> [BTW it seems odd that senders already does what I want in essence, but to
> do it for other things I have to do a recompile with wildlsearch]


That's because testing senders is deemed to be very common, so a special
option is provided for it. Also domains, and local parts. I couldn't
predict everything that people wanted to test, so I invented "condition"
so that you can roll your own tests.

> I know one answer for this expansion problem is to use /N, but I don't
> want to do this - I don't want the string expansion to be possible at all,
> I don't want any user scripts allowed to "execute" ${stuff} anyway.


When I implemented wildlsearch, I called an existing function in Exim
for matching lists - the same function that is used for domain lists
(though in this case the string is forced to be treated as a one-item
list). This means that, as in all lists, the list is expanded first.

I had not thought of the possibility of this being used for user
scripts. I guess I am imagination-challenged...

> How do I do this so that my wildlsearch check is exactly the same as what
> is used for senders = ?


I do not think there is any way to do this at present. I have put an
item on the Wish List.

--
Philip Hazel            University of Cambridge Computing Service,
ph10@???      Cambridge, England. Phone: +44 1223 334714.
Get the Exim 4 book:    http://www.uit.co.uk/exim-book