Merge ~cjwatson/launchpad:loosen-valid-email into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 800c38da63a7be24f07e8a3c23cf10c545d84b62
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:loosen-valid-email
Merge into: launchpad:master
Diff against target: 19 lines (+6/-1)
1 file modified
lib/lp/app/validators/email.py (+6/-1)
Reviewer Review Type Date Requested Status
Thiago F. Pappacena (community) Approve
Review via email: mp+393046@code.launchpad.net

Commit message

Loosen valid_email to accept digits and hyphens in TLDs

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/app/validators/email.py b/lib/lp/app/validators/email.py
2index d54e084..d3789bc 100644
3--- a/lib/lp/app/validators/email.py
4+++ b/lib/lp/app/validators/email.py
5@@ -52,8 +52,13 @@ def valid_email(emailaddr):
6 False
7 >>> valid_email('keith@-risby-family.co.uk')
8 False
9+
10+ The IDNA encoding of internationalised domain names is also accepted.
11+
12+ >>> valid_email('user@example.xn--deba0ad')
13+ True
14 """
15- email_re = r"^[_\.0-9a-zA-Z-+=]+@(([0-9a-zA-Z-]{1,}\.)*)[a-zA-Z]{2,}$"
16+ email_re = r"^[_\.0-9a-zA-Z-+=]+@(([0-9a-zA-Z-]{1,}\.)*)[0-9a-zA-Z-]{2,}$"
17 email_match = re.match(email_re, emailaddr)
18 if not email_match:
19 return False

Subscribers

People subscribed via source and target branches

to status/vote changes: