Colin Watson has proposed merging ~cjwatson/launchpad:loosen-valid-email into 
launchpad:master.

Commit message:
Loosen valid_email to accept digits and hyphens in TLDs

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1280996 in Launchpad itself: "No support for IDNs in email addresses"
  https://bugs.launchpad.net/launchpad/+bug/1280996
  Bug #1902058 in Launchpad itself: "Uploads with malformed email addresses are 
rejected at binary-upload time when they are accepted by dak"
  https://bugs.launchpad.net/launchpad/+bug/1902058

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/393046

This normally comes up in practice when processing package uploads from people 
who've forgotten to set their email address properly so dch(1) generated one 
from their hostname; these are syntactically well-formed despite being 
incorrect, but dak accepts them and we don't have a principled reason to reject 
the upload on that basis.

Digits and hyphens also appear in the IDNA encoding of internationalised domain 
names.  This commit doesn't constitute full support for IDNs, but it makes it 
possible to work around some issues.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~cjwatson/launchpad:loosen-valid-email into launchpad:master.
diff --git a/lib/lp/app/validators/email.py b/lib/lp/app/validators/email.py
index d54e084..d3789bc 100644
--- a/lib/lp/app/validators/email.py
+++ b/lib/lp/app/validators/email.py
@@ -52,8 +52,13 @@ def valid_email(emailaddr):
     False
     >>> valid_email('[email protected]')
     False
+
+    The IDNA encoding of internationalised domain names is also accepted.
+
+    >>> valid_email('[email protected]')
+    True
     """
-    email_re = r"^[_\.0-9a-zA-Z-+=]+@(([0-9a-zA-Z-]{1,}\.)*)[a-zA-Z]{2,}$"
+    email_re = r"^[_\.0-9a-zA-Z-+=]+@(([0-9a-zA-Z-]{1,}\.)*)[0-9a-zA-Z-]{2,}$"
     email_match = re.match(email_re, emailaddr)
     if not email_match:
         return False
_______________________________________________
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp

Reply via email to