Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emails with tlds longer than 3 letters wont pass validation #1

Open
XayOn opened this issue Sep 2, 2020 · 1 comment
Open

Emails with tlds longer than 3 letters wont pass validation #1

XayOn opened this issue Sep 2, 2020 · 1 comment

Comments

@XayOn
Copy link

XayOn commented Sep 2, 2020

As it can bee seen on IANA's TLD list, a lot of domains are more than 3-letter lenght.
https://data.iana.org/TLD/tlds-alpha-by-domain.txt

On client.js, the email validation only allows 3 letter tlds.

if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail)) {

@XayOn
Copy link
Author

XayOn commented Sep 14, 2020

https://stackoverflow.com/questions/201323/how-to-validate-an-email-address-using-a-regular-expression
(?:[a-z0-9!#$%&'*+/=?^_{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])

XayOn added a commit to XayOn/javascript-sdk that referenced this issue Nov 26, 2020
This adds a regex allowing all valid e-mail addresses.

It also removes the unnecesary if, as the return of test function is
always a boolean.
@XayOn XayOn mentioned this issue Nov 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant