]> source.dussan.org Git - vaadin-framework.git/commitdiff
fix: Update regexp pattern of legacy EmailValidator (#12241)
authorTatu Lund <tatu@vaadin.com>
Fri, 12 Mar 2021 16:45:25 +0000 (18:45 +0200)
committerGitHub <noreply@github.com>
Fri, 12 Mar 2021 16:45:25 +0000 (18:45 +0200)
Fixes: https://github.com/vaadin/framework/issues/12240
compatibility-server/src/main/java/com/vaadin/v7/data/validator/EmailValidator.java
compatibility-server/src/test/java/com/vaadin/v7/tests/data/validator/EmailValidatorTest.java
uitest/src/test/java/com/vaadin/tests/VerifyBrowserVersionTest.java

index 2a04b5e625c913bdbb9591f0aa02d5067358a160..9c03c99541922b3fbeff40661d41b4b3efd73b25 100644 (file)
@@ -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);
     }
 }
index e55d5e071e12d4c6b2992ff6a345931a8456db26..1291199ea3fa4a2a655e76de8332a95b7b012910 100644 (file)
@@ -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&"));
+    }
 }
index 87b428a15ad5c7ac994a833b3e355633f4c48f0b..1d668a289a5bb94b2729f76d17d0b9bc86bf0dae 100644 (file)
@@ -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";