-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #820 from rathboma/gmail-dots
Gmail - consecutive dots are not valid
- Loading branch information
Showing
8 changed files
with
65 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,8 +58,16 @@ function isEmail(str, options) { | |
var user = parts.join('@'); | ||
|
||
var lower_domain = domain.toLowerCase(); | ||
|
||
if (lower_domain === 'gmail.com' || lower_domain === 'googlemail.com') { | ||
user = user.replace(/\./g, '').toLowerCase(); | ||
/* | ||
Previously we removed dots for gmail addresses before validating. | ||
This was removed because it allows `[email protected]` | ||
to be reported as valid, but it is not. | ||
Gmail only normalizes single dots, removing them from here is pointless, | ||
should be done in normalizeEmail | ||
*/ | ||
user = user.toLowerCase(); | ||
} | ||
|
||
if (!(0, _isByteLength2.default)(user, { max: 64 }) || !(0, _isByteLength2.default)(domain, { max: 254 })) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,8 +39,16 @@ export default function isEmail(str, options) { | |
let user = parts.join('@'); | ||
|
||
const lower_domain = domain.toLowerCase(); | ||
|
||
if (lower_domain === 'gmail.com' || lower_domain === 'googlemail.com') { | ||
user = user.replace(/\./g, '').toLowerCase(); | ||
/* | ||
Previously we removed dots for gmail addresses before validating. | ||
This was removed because it allows `[email protected]` | ||
to be reported as valid, but it is not. | ||
Gmail only normalizes single dots, removing them from here is pointless, | ||
should be done in normalizeEmail | ||
*/ | ||
user = user.toLowerCase(); | ||
} | ||
|
||
if (!isByteLength(user, { max: 64 }) || | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -235,7 +235,8 @@ describe('Sanitizers', function () { | |
'[email protected]': '[email protected]', | ||
'[email protected]': '[email protected]', | ||
'hans@m端ller.com': 'hans@m端ller.com', | ||
'[email protected]': '[email protected]', | ||
'[email protected]': '[email protected]', | ||
'[email protected]': '[email protected]', | ||
'"foo@bar"@baz.com': '"foo@bar"@baz.com', | ||
}, | ||
}); | ||
|
@@ -326,6 +327,7 @@ describe('Sanitizers', function () { | |
expect: { | ||
'[email protected]': '[email protected]', | ||
'[email protected]': '[email protected]', | ||
'[email protected]': '[email protected]', | ||
'[email protected]': '[email protected]', | ||
}, | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,6 @@ describe('Validators', function () { | |
'test|123@m端ller.com', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'"foobar"@example.com', | ||
'" foo m端ller "@example.com', | ||
'"foo\\@bar"@example.com', | ||
|
@@ -84,6 +83,9 @@ describe('Validators', function () { | |
'[email protected] m', | ||
'[email protected] m', | ||
'[email protected] m', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
], | ||
}); | ||
}); | ||
|
@@ -162,6 +164,7 @@ describe('Validators', function () { | |
'Some Name <[email protected].', | ||
'Some Name < [email protected] >', | ||
'Name [email protected]', | ||
'Some Name <[email protected]>', | ||
], | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -203,8 +203,16 @@ function isEmail(str, options) { | |
var user = parts.join('@'); | ||
|
||
var lower_domain = domain.toLowerCase(); | ||
|
||
if (lower_domain === 'gmail.com' || lower_domain === 'googlemail.com') { | ||
user = user.replace(/\./g, '').toLowerCase(); | ||
/* | ||
Previously we removed dots for gmail addresses before validating. | ||
This was removed because it allows `[email protected]` | ||
to be reported as valid, but it is not. | ||
Gmail only normalizes single dots, removing them from here is pointless, | ||
should be done in normalizeEmail | ||
*/ | ||
user = user.toLowerCase(); | ||
} | ||
|
||
if (!isByteLength(user, { max: 64 }) || !isByteLength(domain, { max: 254 })) { | ||
|
@@ -1415,6 +1423,14 @@ var outlookdotcom_domains = ['hotmail.at', 'hotmail.be', 'hotmail.ca', 'hotmail. | |
// This list is likely incomplete | ||
var yahoo_domains = ['rocketmail.com', 'yahoo.ca', 'yahoo.co.uk', 'yahoo.com', 'yahoo.de', 'yahoo.fr', 'yahoo.in', 'yahoo.it', 'ymail.com']; | ||
|
||
// replace single dots, but not multiple consecutive dots | ||
function dotsReplacer(match) { | ||
if (match.length > 1) { | ||
return match; | ||
} | ||
return ''; | ||
} | ||
|
||
function normalizeEmail(email, options) { | ||
options = merge(options, default_normalize_email_options); | ||
|
||
|
@@ -1432,7 +1448,8 @@ function normalizeEmail(email, options) { | |
parts[0] = parts[0].split('+')[0]; | ||
} | ||
if (options.gmail_remove_dots) { | ||
parts[0] = parts[0].replace(/\./g, ''); | ||
// this does not replace consecutive dots like example..email@gmail.com | ||
parts[0] = parts[0].replace(/\.+/g, dotsReplacer); | ||
} | ||
if (!parts[0].length) { | ||
return false; | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.