commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bruno P. Kinoshita (Commented) (JIRA)" <>
Subject [jira] [Commented] (VALIDATOR-302) EMailValidator: Addresses with leading spaces must not be accepted
Date Mon, 16 Apr 2012 04:24:42 GMT


Bruno P. Kinoshita commented on VALIDATOR-302:

Hi there, 

I have started using Apache Commons Validator in a new project, and I'm reading the code and
issues. I read the code base and some specs to check if there was anything mentioning leading
spaces. Here's what I found so far: 

- EmailValidatorTest tests 'new ResultPair("", true),' and mentions RFC
- I couldn't find in RFC822 [1] whether this is legal or illegal
- RFC 5322, appendix 5 [2] says it's fine to have spaces: "The above example is aesthetically
displeasing, but perfectly legal. (...) , and the folding white space before and after ","".

It's not permitted to have leading spaces between @, and it's being validated correctly in
the current API

- RFC 5322, section 3.4.1 [3]: Comments and folding white space SHOULD NOT be used around
the "@" in the addr-spec. 

If this behavior is changed, tests would have to be updated as well. The current behavior
is the same as Perl's Email::Valid module [4]

I would go with letting the called code decide whether to trim the address or not. This way
the Validator API would say that the address is fine, and then the mailer-tool would have
to extract the mailbox name from the e-mail address. I believe most tools would execute a
trim in the e-mail given before inserting the e-mail address in a database or so. 

Just my 0.02 cents :) 

> EMailValidator: Addresses with leading spaces must not be accepted
> ------------------------------------------------------------------
>                 Key: VALIDATOR-302
>                 URL:
>             Project: Commons Validator
>          Issue Type: Bug
>          Components: Routines
>            Reporter: Guido Zockoll
>     @Test
>     public void testEmailValidatorBug() {
>         // The commons validator class accepts an address with an leading whitespace
which seams to be a bug.
>         boolean shouldBe = false;
>         boolean isActual = true;
>         String eMail = "";
>         logger.debug("{} is {}", eMail, validator.isValid(eMail) ? "valid" : "invalid");
>         assertThat("Check failed for " + eMail, validator.isValid(eMail), is(isActual));
>     }

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message