Autor: John Burnham Datum: To: 'exim-users@exim.org' Betreff: Re: [exim] nwildlsearch
> > > So your answer suggests that I am right. > >
> > I think I'm confused about what you're asking then.
>
> Sorry, my english might not be the best. Its not my mother thong.
>
Not a problem - I just wanted clarification. If I don't understand your problem I can't be of much help. Thanks for the example.
> Hmmm. I meant it more the other way around.
>
> I have a map file with:
>
> ^bla\..*@example.com
>
> Now I do a lookup like:
> ${lookup{bla.me@???}nwildlsearch{/map/file}{true}{false}}
>
> So far so clear. But what if I do the following:
> ${lookup{bla.me@???%bad.domain}nwildlsearch{/map/file}
> {true}{false}}
>
> Will that match too? Do I have to add a '$' at the end of the
> key in the
> map file to not match?
>
> For lsearch, the case is clearly documented. But with
> (n)wildlsearch it
> is not completely clear.
>
if in doubt, give it a test. I've created a file called /map/file containing
^bla\..*@example.com: result
So, I run exim -d -be
> ${lookup{bla.me@???}nwildlsearch{/map/file}{true}{false}} search_open: nwildlsearch "/map/file"
search_find: file="/map/file"
key="bla.me@???" partial=-1 affix=NULL starflags=0
LRU list:
?/map/file
End
internal_search_find: file="/map/file"
type=nwildlsearch key="bla.me@???"
file lookup required for bla.me@???
in /map/file
bla.me@??? in "^bla\..*@example.com"? yes (matched "^bla\..*@example.com")
lookup yielded: result
true
So, as you see, that works as you said. Now let's try your other example:
${lookup{bla.me@???%bad.domain}nwildlsearch{/map/file}{true}{false}}
search_open: nwildlsearch "/map/file"
cached open
search_find: file="/map/file"
key="bla.me@???%bad.domain" partial=-1 affix=NULL starflags=0
LRU list:
?/map/file
End
internal_search_find: file="/map/file"
type=nwildlsearch key="bla.me@???%bad.domain"
file lookup required for bla.me@???%bad.domain
in /map/file
bla.me@???%bad.domain in "^bla\..*@example.com"? yes (matched "^bla\..*@example.com")
lookup yielded: result
true
So, yes, that also matches.
Now let's add a $ to /map/file so it contains:
^bla\..*@example.com$: result
and run that test again:
exim -d -be > ${lookup{bla.me@???%bad.domain}nwildlsearch{/map/file}{true}{false}} search_open: nwildlsearch "/map/file"
search_find: file="/map/file"
key="bla.me@???%bad.domain" partial=-1 affix=NULL starflags=0
LRU list:
?/map/file
End
internal_search_find: file="/map/file"
type=nwildlsearch key="bla.me@???%bad.domain"
file lookup required for bla.me@???%bad.domain
in /map/file
bla.me@???%bad.domain in "^bla\..*@example.com$"? no (end of list)
lookup failed
false
So, that returns false. I think I understand now what you means by begins with - with a wildcard lsearch using regular expressions then if you don't put a $ at the end then it matches because the beginning matches and you haven't defined how it should end. The $ at the end defines how the regular expression should end.
Sorry, I hope that answers your question. I hope it also shows how useful exim -be can be when trying to figure these things out.