|
From: | Robin Farine |
Subject: | Re: [Gnu-arch-users] [Patch] Underscores in 'make-archive' e-mail |
Date: | Wed, 24 Mar 2004 23:45:45 +0100 |
User-agent: | Mozilla Thunderbird 0.5 (X11/20040306) |
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"
[Prev in Thread] | Current Thread | [Next in Thread] |