[hibernate-issues] [Hibernate-JIRA] Updated: (HV-591) EmailValidator throws an IllegalArgumentException for long email addresses
Hardy Ferentschik (JIRA)
noreply at atlassian.com
Fri May 18 04:37:11 EDT 2012
[ https://hibernate.onjira.com/browse/HV-591?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Hardy Ferentschik updated HV-591:
---------------------------------
Description:
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 at 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 at 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}
was:
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.
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa at hibernate.org
In EmailValidator.java:
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();
}
A test:
@Test
public void testForLongEmailAddresses(){
final String longEmail = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa at 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");
}
> 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 at 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 at 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: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list