You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Email Pattern accepts double dot between domain and tld #17333
I'm using an EmailField without overriding the validation pattern.
An email like "example@gmail..com" is not considered invalid (using emailField.isInvalid())
I got an exception from javax.mail.internet.InternetAddress when I send an email to this address:
Caused by: javax.mail.internet.AddressException: Domain contains dot-dot
at javax.mail.internet.InternetAddress.checkAddress(InternetAddress.java:1413) ~[jakarta.mail-1.6.7.jar!/:1.6.7]
at javax.mail.internet.InternetAddress.parse(InternetAddress.java:1191) ~[jakarta.mail-1.6.7.jar!/:1.6.7]
at javax.mail.internet.InternetAddress.parse(InternetAddress.java:728) ~[jakarta.mail-1.6.7.jar!/:1.6.7]
at javax.mail.internet.InternetAddress.parse(InternetAddress.java:705) ~[jakarta.mail-1.6.7.jar!/:1.6.7]
Expected behavior
The method isInvalid() should return true when email address contains multiple dots (like example@gmail..com)
EmailField allows two consecutive dots in the domain, also EmailValidator uses the same email pattern. Thus, the fix should go to both Flow and Flow-components (EmailField).
private static final String PATTERN = "^" + "([a-zA-Z0-9_\\.\\-+])+" // local
+ "@" + "([a-zA-Z0-9-]+\\.)+" // domain with the separator dot before the tld
+ "[a-zA-Z0-9-]{2,}$" // tld
+ "$";
and the method for testing it:
@Test
public void testDomainWithDotDotFails() {
EmailValidator v = validator("domains containing dot dot should fail");
assertFails("hello@sample..com", v);
assertFails("hello@samp..le..com", v);
}
Can i reference EmailValidator pattern into EmailField class to remove its duplication (the pattern would then be public) ?
Activity
mshabarov commentedon Aug 1, 2023
EmailFieldallows two consecutive dots in the domain, alsoEmailValidatoruses the same email pattern. Thus, the fix should go to both Flow and Flow-components (EmailField).tip:
(?!.*\.\.)- don't allow 2 consecutive dots.@yuriy-fix FYI
gronono commentedon Aug 1, 2023
@mshabarov I will try to make a pull request by the end of the week
gronono commentedon Aug 3, 2023
The new Regex :
and the method for testing it:
Can i reference EmailValidator pattern into EmailField class to remove its duplication (the pattern would then be public) ?
fix: vaadin#17333 Email pattern accepts double dot between domain and…
fix: Email pattern accepts double dot between domain and tld (vaadin#…
fix: Email pattern accepts double dot between domain and tld (vaadin/…
fix: Email pattern accepts double dot between domain and tld (vaadin#…
fix: Email pattern accepts double dot between domain and tld (vaadin#…
fix: reject emails with double dot between domain and tld (#17353)
8 remaining items
fix: reject emails with double dot between domain and tld (#5327)
fix: reject emails with double dot between domain and tld (#5327)
fix: reject emails with double dot between domain and tld (#5327)
fix: reject emails with double dot between domain and tld (#5327) (#5332
fix: reject emails with double dot between domain and tld (#5327) (#5333
fix: reject emails with double dot between domain and tld (#5327) (#5334
vaadin-bot commentedon Aug 8, 2023
This ticket/PR has been released with Vaadin 24.2.0.alpha6 and is also targeting the upcoming stable 24.2.0 version.
vaadin-bot commentedon Aug 14, 2023
This ticket/PR has been released with Vaadin 23.3.20.
vaadin-bot commentedon Aug 14, 2023
This ticket/PR has been released with Vaadin 24.0.12.
vaadin-bot commentedon Aug 14, 2023
This ticket/PR has been released with Vaadin 24.1.5.