gnu-arch-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnu-arch-users] [Patch] Underscores in 'make-archive' e-mail


From: Jan Hudec
Subject: Re: [Gnu-arch-users] [Patch] Underscores in 'make-archive' e-mail
Date: Fri, 26 Mar 2004 22:23:32 +0100
User-agent: Mutt/1.5.5.1+cvs20040105i

On Wed, Mar 24, 2004 at 23:45:45 +0100, Robin Farine wrote:
> address@hidden wrote:
> 
> >So IMO it's pretty clear that the domain part of an e-mail address *does*
> >have the restrictions that a DNS domain has.
> > 
> >
> 
> Ouch, naturally you are correct. Now I also looked at rfc2821 which 
> better describes actual restrictions on Internet e-mail addresses. There 
> are also some MUST and SHOULD restrictions on the local part. Assuming 
> that we can drop the quoted string form and the nested comments, I 
> propose the following python code as approximation of an e-mail address 
> verifier (it prints the regexp which is a bit long to figure here).  
> Also, the  domain literal form is not accepted but it does not make much 
> sense in an Arch archive name, right?
> 
> Comments welcome.
> 
> Robin
> 
> #! /usr/bin/env python
> 
> import re, sys
> 
> alnum = "[0-9A-Za-z]"
> alnumhyph = "[-0-9A-Za-z]"
> label = alnum + "(" + alnumhyph + "*" + alnum + ")?"
> domain = label + "(\." + label + ")*"
> 
> atext = "[-0-9A-Za-z!#$%&'*+/=?^_`{|}~]"
> local = atext + "+" + "(\." + atext + "+" + ")*"
> email = "^" + local + "@" + domain + "$"
> print email
> 
> emailre = re.compile(email)
> 
> if emailre.match(sys.argv[1]):
>    print "ok"
> else:
>    print "nope"

And since tla is equiped with regular expression engine, I'd translate
the above to following cpp code, that can be included in some tla header
and used for the checking:

#define ALNUM_RE "[0-9A-Za-z]"
#define ALNUMHYPH_RE "[-0-9A-Za-z]"
#define LABEL_RE ALNUM_RE "(" ALNUMHYPH_RE "*" ALNUM_RE ")?"
#define DOTATOM_RE(re) re "(\." re ")*"
#define DOMAIN_RE DOTATOM_RE(LABEL_RE)
#define ATEXT_RE "[-0-9A-Za-z!#$%&'*+/=?^_`{|}~]+"
#define LOCAL_RE DOTATOM_RE(ATEXT_RE)
#define EMAIL_RE LOCAL_RE "@" DOMAIN_RE

Note -- I have excluded the ^ and $ around EMAIL_RE, because it will be
part of ARCHIVE_RE.

-------------------------------------------------------------------------------
                                                 Jan 'Bulb' Hudec 
<address@hidden>

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]