RE: [Exim] regex and email validation

Góra strony
Delete this message
Reply to this message
Autor: Hämäläinen Jori
Data:  
Dla: exim-users
Temat: RE: [Exim] regex and email validation
I was also thinking about the block of the first test
case. I think blocking happened by accident..

Regexp goes:
^            # start of string
.            # any character
[a-z0-9_-]+        # characterlist, match 1 or more
(...)


tést would block because "." matches to "t" and next
char should be from your list.

My point would be that if address had been:
atést@         # with this \ - escapething which Philip pointed out
ést@            # with this first char being "."
mails would probably go through.


If you need to be prepared of <> -'tags' outside of email
address (as you probably would with "^" starting the regexp),
I think you should match <? and >? (0 or 1 times) (instead
blind of ".")

<?[a-z0-9_-]+....(\.[a-z0-9_-]+)+>?

Best regards, Jori Hämäläinen

> -----Original Message-----
> From: Philip Hazel [mailto:ph10@cus.cam.ac.uk]
> Sent: 24. helmikuuta 2003 12:09
> To: Abaddon
> Cc: exim-users@???
> Subject: 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.

>
>
> --
>
> ## List details at

http://www.exim.org/mailman/listinfo/exim-users Exim details at http://www.exim.org/ ##