- From: Erik Bruchez <ebruchez@orbeon.com>
- Date: Fri, 23 Jun 2017 09:48:46 -0700
- To: Steven Pemberton <steven.pemberton@cwi.nl>
- Cc: "public-xformsusers@w3.org" <public-xformsusers@w3.org>
- Message-ID: <CAAc0PEW+2_Fc0yPXbhJTsyZNvbJMkgEvEZX-Do1WiB4Xvk+wtw@mail.gmail.com>
Email validation is always wrong ;)
We had a few issues with this in our implementation:
- "Email validation is too lax" [1], which is exactly your scenario
- "Email validation too strict on TLDs supported" [2]
So instead of the regexp in the spec we now use the Apache email validator
[3] ("This implementation is not guaranteed to catch all possible errors in
an email address") and then we do our own domain validation:
// Modified email validator which:
//
// 1. Doesn't check whether a TLD is known, as there are two many of
those now (2015) and changing constantly.
// 2. Doesn't support IP addresses (we probably could, but we don't care
right now).
//
object EmailValidatorNoDomainValidation extends EmailValidator(false) {
private val DomainLabelRegex = "\\p{Alnum}(?>[\\p{Alnum}-]*\\p{Alnum})*"
private val TopLabelRegex = "\\p{Alpha}{2,}"
private val DomainNameRegex = "^(?:" + DomainLabelRegex + "\\.)+" +
"(" + TopLabelRegex + ")$"
private val DomainRegex = new RegexValidator(DomainNameRegex)
override def isValidDomain(domain: String) =
Option(DomainRegex.`match`(domain)) exists (_.nonEmpty)
}
This does require at least one "." and handles your case.
-Erik
[1] https://github.com/orbeon/orbeon-forms/issues/1347
[2] https://github.com/orbeon/orbeon-forms/issues/2116
[3] https://commons.apache.org/proper/commons-validator/apidocs/
org/apache/commons/validator/routines/EmailValidator.html
On Fri, Jun 23, 2017 at 4:28 AM, Steven Pemberton <steven.pemberton@cwi.nl>
wrote:
> Our definition of email accepts the following as a valid email address:
>
> steven@cwi
>
> Are we OK with that? I'd expect at least one "." after the @.
>
> Steven
>
>
Received on Friday, 23 June 2017 16:49:39 UTC