From: Tatu Lund Date: Fri, 12 Mar 2021 16:45:25 +0000 (+0200) Subject: fix: Update regexp pattern of legacy EmailValidator (#12241) X-Git-Tag: 8.13.0.beta1~9 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=754ca011d79af3dd4fa9046ff0ade5367f5e6246;p=vaadin-framework.git fix: Update regexp pattern of legacy EmailValidator (#12241) Fixes: https://github.com/vaadin/framework/issues/12240 --- 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";