Skip to content

Commit

Permalink
fix: Update regexp pattern of legacy EmailValidator (#12241)
Browse files Browse the repository at this point in the history
Fixes: #12240
  • Loading branch information
TatuLund authored Mar 12, 2021
1 parent 9978eec commit 754ca01
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
@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.
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ public void testEmailValidatorWithFaultyString() {
public void testEmailValidatorWithOkEmail() {
assertTrue(validator.isValid("[email protected]"));
}

@Test
public void testEmailValidatorWithBadInput() {
assertFalse(validator.isValid("[email protected]&"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void verifyUserAgent() {
// 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";
Expand Down

0 comments on commit 754ca01

Please sign in to comment.