diff options
Diffstat (limited to 'compatibility-server')
-rw-r--r-- | compatibility-server/src/main/java/com/vaadin/v7/data/validator/EmailValidator.java | 8 | ||||
-rw-r--r-- | compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/EmailValidatorTest.java | 5 |
2 files changed, 11 insertions, 2 deletions
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/validator/EmailValidator.java b/compatibility-server/src/main/java/com/vaadin/v7/data/validator/EmailValidator.java index 2a04b5e625..9c03c99541 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/validator/EmailValidator.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/validator/EmailValidator.java @@ -35,6 +35,11 @@ package com.vaadin.v7.data.validator; @Deprecated public class EmailValidator extends RegexpValidator { + private static final String PATTERN = "^" + "([a-zA-Z0-9_\\.\\-+])+" // local + + "@" + "[a-zA-Z0-9-.]+" // domain + + "\\." + "[a-zA-Z0-9-]{2,}" // tld + + "$"; + /** * Creates a validator for checking that a string is a syntactically valid * e-mail address. @@ -43,7 +48,6 @@ public class EmailValidator extends RegexpValidator { * the message to display in case the value does not validate. */ public EmailValidator(String errorMessage) { - super("^([a-zA-Z0-9_\\.\\-+])+@(([a-zA-Z0-9-])+\\.)+([a-zA-Z0-9]{2,4})+$", - true, errorMessage); + super(PATTERN, true, errorMessage); } } diff --git a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/EmailValidatorTest.java b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/EmailValidatorTest.java index e55d5e071e..1291199ea3 100644 --- a/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/EmailValidatorTest.java +++ b/compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/EmailValidatorTest.java @@ -30,4 +30,9 @@ public class EmailValidatorTest { public void testEmailValidatorWithOkEmail() { assertTrue(validator.isValid("my.name@email.com")); } + + @Test + public void testEmailValidatorWithBadInput() { + assertFalse(validator.isValid("a@a.m5qRt8zLxQG4mMeu9yKZm5qRt8zLxQG4mMeu9yKZm5qRt8zLxQG4mMeu9yKZ&")); + } } |