diff options
author | Tatu Lund <tatu@vaadin.com> | 2021-03-12 18:45:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-12 18:45:25 +0200 |
commit | 754ca011d79af3dd4fa9046ff0ade5367f5e6246 (patch) | |
tree | ad4cff63e7b0c77445cafdbb7ab7f18bf66541c1 /compatibility-server | |
parent | 9978eec85cb95df26170006a04d2285cfd7bcc7d (diff) | |
download | vaadin-framework-754ca011d79af3dd4fa9046ff0ade5367f5e6246.tar.gz vaadin-framework-754ca011d79af3dd4fa9046ff0ade5367f5e6246.zip |
fix: Update regexp pattern of legacy EmailValidator (#12241)
Fixes: https://github.com/vaadin/framework/issues/12240
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&")); + } } |