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

Gmail - consecutive dots are not valid #820

Merged
merged 4 commits into from
May 3, 2018

Conversation

rathboma
Copy link
Contributor

Fixes #818

While single dots in email addresses are ignored by Google, multiple consecutive dots are not, and in fact sending to an email with multiple dots inserted will result in a bounce.

Here is a speculative fix for that issue, with tests. It has one specific behavior that might be contentious, but I think may be the best balance:

On email normalization, it does NOT replace multiple consecutive dots, only single dots, regardless of the replace_dots option, because gmail itself doesn't do this behavior either.

chriso and others added 4 commits April 20, 2018 14:11
Show optional fields

fix for gmail parsing and validation

trailing commas fml
- multiple dots are not valid and should fail validation
- normailzation should not replace consecutive dots
@rathboma
Copy link
Contributor Author

I've updated this to strip some un-needed gmail-specific logic from isEmail that in fact introduced a bug. Multiple consecutive dots in the user part of the email is invalid, regardless of domain. The gmail specific logic was causing this to be reported as valid.

See here for context:
https://serverfault.com/questions/395766/are-two-periods-allowed-in-the-local-part-of-an-email-address

I'm keeping the behavior in normalizeEmail to leave multiple consecutive dots in normalized gmail addresses as this is not something that gmail itself normalizes, so now you can call isEmail(normalizeEmail('[email protected]')) and get the correct result.

@rathboma
Copy link
Contributor Author

rathboma commented May 2, 2018

@chriso would love to get your take on this fix. I did add testing and we're using it in production right now at Kickbox.

@chriso
Copy link
Collaborator

chriso commented May 3, 2018

Thanks for the PR, this looks correct.

@chriso chriso merged commit 80fb30d into validatorjs:master May 3, 2018
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

Successfully merging this pull request may close these issues.

Invalid gmail addresses with multiple dots are marked as valid and the dots are normalized out
2 participants