Re: [Exim] regex and email validation

Góra strony
Delete this message
Reply to this message
Autor: Philip Hazel
Data:  
Dla: Abaddon
CC: exim-users
Temat: Re: [Exim] regex and email validation
On Mon, 24 Feb 2003, Abaddon wrote:

> Hello, i am trying to make a ACL the deny emails
> with strange characthers, like:
>
>   deny    senders       = !
> ^.[a-z0-9_-]+(\.[a-z0-9_-]+)*@[a-z0-9_-]+(\.[a-z0-9_-]+)+

>
> If somene issues:
>
> mail from: tést@???
>
> it will deny, but
>
> mail from: test%as@???
>
> it will not deny...
>
> Is this regex wrong ?


Yes.

Lists in ACLs are string-expanded. Thus, \ is an escape character for
the expansion, and will have been removed from the regex before it is
processed. What the regex engine is seeing is

^.[a-z0-9_-]+(.[a-z0-9_-]+)*@[a-z0-9_-]+(.[a-z0-9_-]+)+

Can you now see why it fails?

The easiest way round this is to wrap your regex in \N...\N
so that the internal backslashes are left alone.

--
Philip Hazel            University of Cambridge Computing Service,
ph10@???      Cambridge, England. Phone: +44 1223 334714.