[hibernate-issues] [Hibernate-JIRA] Created: (HV-339) ^ not allowed in Email

Tim (JIRA) noreply at atlassian.com
Tue Jun 22 19:59:09 EDT 2010


^ not allowed in Email
----------------------

                 Key: HV-339
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-339
             Project: Hibernate Validator
          Issue Type: Bug
          Components: validators
    Affects Versions: 4.1.0.CR1
         Environment: hibernate-validator-4.1.0.CR1
            Reporter: Tim
            Assignee: Hardy Ferentschik
            Priority: Minor


The email validator rejects emails with ^ in them.  According to the rfc-2822 spec they should be allowed. 

http://www.faqs.org/rfcs/rfc2822.html

I believe the regex is incorrect.  
>From file org.hibernate.validator.constraints.impl.EmailValidator  (line 17)

private static String ATOM = "[^\\x00-\\x1F^\\(^\\)^\\<^\\>^\\@^\\,^\\;^\\:^\\\\^\\\"^\\.^\\[^\\]^\\s]";

There should only be one ^ all the others are not needed and cause the ^ character to be invalid.

I believe it should be:
private static String ATOM = "[^\\x00-\\x1F\\(\\)\\<\\>\\@\\,\\;\\:\\\\\\\"\\.\\[\\]\\s]";

// ======== Test Case =========
import junit.framework.TestCase;
import org.hibernate.validator.constraints.impl.EmailValidator;
import org.junit.Test;

public class TestEmailValidator extends TestCase {

    @Test
    public void testAccent(){
        EmailValidator emailValidator = new EmailValidator();
        boolean result = emailValidator.isValid("Test^Email at example.com", null);
        assertTrue(result);
    }
}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list