aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTatu Lund <tatu@vaadin.com>2021-03-12 18:45:25 +0200
committerGitHub <noreply@github.com>2021-03-12 18:45:25 +0200
commit754ca011d79af3dd4fa9046ff0ade5367f5e6246 (patch)
treead4cff63e7b0c77445cafdbb7ab7f18bf66541c1
parent9978eec85cb95df26170006a04d2285cfd7bcc7d (diff)
downloadvaadin-framework-754ca011d79af3dd4fa9046ff0ade5367f5e6246.tar.gz
vaadin-framework-754ca011d79af3dd4fa9046ff0ade5367f5e6246.zip
fix: Update regexp pattern of legacy EmailValidator (#12241)
Fixes: https://github.com/vaadin/framework/issues/12240
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/data/validator/EmailValidator.java8
-rw-r--r--compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/EmailValidatorTest.java5
-rw-r--r--uitest/src/test/java/com/vaadin/tests/VerifyBrowserVersionTest.java2
3 files changed, 12 insertions, 3 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&"));
+ }
}
diff --git a/uitest/src/test/java/com/vaadin/tests/VerifyBrowserVersionTest.java b/uitest/src/test/java/com/vaadin/tests/VerifyBrowserVersionTest.java
index 87b428a15a..1d668a289a 100644
--- a/uitest/src/test/java/com/vaadin/tests/VerifyBrowserVersionTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/VerifyBrowserVersionTest.java
@@ -25,7 +25,7 @@ public class VerifyBrowserVersionTest extends MultiBrowserTest {
// Chrome version does not necessarily match the desired version
// because of auto updates...
browserIdentifier = getExpectedUserAgentString(
- getDesiredCapabilities()) + "87";
+ getDesiredCapabilities()) + "89";
} else if (BrowserUtil.isFirefox(getDesiredCapabilities())) {
browserIdentifier = getExpectedUserAgentString(
getDesiredCapabilities()) + "81";