You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Sébastien De Nef <se...@gmail.com> on 2015/10/22 09:05:14 UTC

[validator] EmailValidator accept empty domain names

Hi everybody,

First, sorry for my english.

I tried the EmailValidator component and I was surprised that it accepts a
domain part that contains only the TLD (like joe@.org). See below a failing
test.

Although domainValidator.isValid(domain) returns false
domainValidator.isValid(domain) || domainValidator.isValidTld(domain)
returns true
Is it the source of the problem ? Why does it bypass the domain validation
if the TLD is valid ?
NB: DomainValidator.isValid already contains isValidTld()

Sébastien

/**
* Tests the email validation for empty domain.
*/
public void testEmailWithEmptyDomain()  {
    assertFalse("empty domain name should fail",
emailValidator.commonsValidator("joe@"));
    assertFalse("domain name starting with dot should fail",
emailValidator.commonsValidator("joe@.apache.org"));
    assertFalse("domain name with only TLD should fail",
emailValidator.commonsValidator("joe@.org")); // yes or no ?
}

Re: [validator] EmailValidator accept empty domain names

Posted by Ralph Goers <ra...@dslextreme.com>.
Please see VALIDATOR-376. I just committed the fix for this. FYI - commons-validator 1.4 does not have this behavior.

Ralph



> On Oct 22, 2015, at 12:05 AM, Sébastien De Nef <se...@gmail.com> wrote:
> 
> Hi everybody,
> 
> First, sorry for my english.
> 
> I tried the EmailValidator component and I was surprised that it accepts a
> domain part that contains only the TLD (like joe@.org). See below a failing
> test.
> 
> Although domainValidator.isValid(domain) returns false
> domainValidator.isValid(domain) || domainValidator.isValidTld(domain)
> returns true
> Is it the source of the problem ? Why does it bypass the domain validation
> if the TLD is valid ?
> NB: DomainValidator.isValid already contains isValidTld()
> 
> Sébastien
> 
> /**
> * Tests the email validation for empty domain.
> */
> public void testEmailWithEmptyDomain()  {
>    assertFalse("empty domain name should fail",
> emailValidator.commonsValidator("joe@"));
>    assertFalse("domain name starting with dot should fail",
> emailValidator.commonsValidator("joe@.apache.org"));
>    assertFalse("domain name with only TLD should fail",
> emailValidator.commonsValidator("joe@.org")); // yes or no ?
> }



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org