Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/lib/isEmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ export default function isEmail(str, options) {

if (options.domain_specific_validation && (lower_domain === 'gmail.com' || lower_domain === 'googlemail.com')) {
/*
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
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();

Expand Down Expand Up @@ -166,7 +166,7 @@ export default function isEmail(str, options) {
if (user.search(new RegExp(`[${options.blacklisted_chars}]+`, 'g')) !== -1) return false;
}

if (user[0] === '"') {
if (user[0] === '"' && user[user.length - 1] === '"') {
user = user.slice(1, user.length - 1);
return options.allow_utf8_local_part ?
quotedEmailUserUtf8.test(user) :
Expand Down
4 changes: 4 additions & 0 deletions test/validators.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,16 @@ describe('Validators', () => {
'[email protected]',
'[email protected]',
`${'a'.repeat(30)}@gmail.com`,
'"foobar"@gmail.com',
],
invalid: [
`${'a'.repeat(31)}@gmail.com`,
'[email protected]',
'[email protected]',
'[email protected]',
'"[email protected]',
'"foo"[email protected]',
'foo"bar"@gmail.com',
],
});
});
Expand Down