[
https://issues.apache.org/jira/browse/VALIDATOR-302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13254505#comment-13254505
]
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(" [email protected]", true),' and
mentions RFC 822.
- 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 "[email protected],"".
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 :)
[1] http://www.ietf.org/rfc/rfc0822.txt
[2] http://tools.ietf.org/html/rfc5322#appendix-A.5
[3] http://tools.ietf.org/html/rfc5322#section-3.4.1
[4] http://search.cpan.org/search?mode=module&query=Email%3A%3AValid
> EMailValidator: Addresses with leading spaces must not be accepted
> ------------------------------------------------------------------
>
> Key: VALIDATOR-302
> URL: https://issues.apache.org/jira/browse/VALIDATOR-302
> 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 = " [email protected]";
> 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:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira