- From: Steven Pemberton <steven.pemberton@cwi.nl>
- Date: Fri, 23 Jun 2017 21:12:54 +0200
- To: "Erik Bruchez" <ebruchez@orbeon.com>
- Cc: "public-xformsusers@w3.org" <public-xformsusers@w3.org>
- Message-ID: <op.y2avnskqsmjzpq@steven-xps>
We define the email type as:
<xs:restriction base="xs:string">
<xs:pattern
value="([A-Za-z0-9!#-'\*\+\-/=\?\^_`\{-~]+(\.[A-Za-z0-9!#-'\*\+\-/=\?\^_`\{-~]+)*
@[A-Za-z0-9!#-'\*\+\-/=\?\^_`\{-~]+(\.[A-Za-z0-9!#-'\*\+\-/=\?\^_`\{-~]+)*)?"/>
</xs:restriction>
</xs:simpleType>
To help understand the above pattern, it can be split up as follows:
char=[A-Za-z0-9!#-'\*\+\-/=\?\^_`\{-~]
seg=char+
segs=seg(.seg)*
address=segs@segs
email=address?
If we changed the last "*" in the regexp to a "+", it would require at
least two 'seg's after the "@", thus allowing steven@cwi.nl, and not
allowing steven@cwi
Steven
On Fri, 23 Jun 2017 18:48:46 +0200, Erik Bruchez <ebruchez@orbeon.com>
wrote:
> 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 19:13:29 UTC