REGEX_MAIL in ValidationUtil is too restrictive

Issue #905 resolved
Gábor Stefanik created an issue

REGEX_MAIL currently assumes an e-mail address in the format <name>@<domain>.<tld>, where <domain> is at least 2 characters long, and <tld> is between 2 and 6 characters, inclusive.

This prevents creating a repository with mike@ucla.college, jerry@t.co, or webmaster@home.cancerresearch (all potentially valid) as the contact person, despite all of these being valid domains and potentially live e-mail addresses.

Additionally, the TLD is assumed to contain only alphanumeric characters, which is violated by internationalized TLDs (which, when encoded using punycode, will also contain hyphens). So, mikhail@xn--j1ay.xn--p1ai (decoded: mikhail@кц.рф, also a valid and live domain) can't be a repository contact person.

The current regex is: "^[A-z0-9][\\w.-]*@[A-z0-9][\\w\\-\\.]+\\.[A-z0-9]{2,6}$"

I would suggest changing it to: "^[A-z0-9][\\w.-]*@[A-z0-9][\\w\\-\\.]*\\.[A-z0-9-]{2,}$"

This enables one-character 2nd-level domain names (like t.co), TLDs longer than 6 chars (like .college) and TLDs containing hyphens (like .рф AKA .xn--p1ai)

Comments (2)

  1. Log in to comment