]
Hardy Ferentschik updated HV-591:
---------------------------------
Pull Requests:
EmailValidator throws an IllegalArgumentException for long email
addresses
--------------------------------------------------------------------------
Key: HV-591
URL:
https://hibernate.onjira.com/browse/HV-591
Project: Hibernate Validator
Issue Type: Bug
Components: validators
Affects Versions: 4.3.0.Final, 5.x
Reporter: Marco Ramirez
Labels: validation
When I attempt to validate the email address below the IDN.toASCII call throws an
exception because it's using the entire email address and not just the domain, eg
_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(a)hibernate.org_
In _EmailValidator.java_:
{code}
public boolean isValid(CharSequence value, ConstraintValidatorContext context) {
if ( value == null || value.length() == 0 ) {
return true;
}
String asciiString = IDN.toASCII( value.toString() ); //<- fails here
Matcher m = pattern.matcher( asciiString );
return m.matches();
}
{code}
A test:
{code}
@Test
public void testForLongEmailAddresses(){
final String longEmail =
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(a)hibernate.org";
IllegalArgumentException e = null;
try{
new EmailValidator().isValid(longEmail, null);
}catch (IllegalArgumentException f){
e = f;
}
assertTrue(e == null, "IllegalArgumentException thrown while validating
email address");
}
{code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: