Skip to content

Commit

Permalink
fix(isEmail): email starting with double quotes (#2437)
Browse files Browse the repository at this point in the history
fixes #2432
  • Loading branch information
code0emperor authored Aug 15, 2024
1 parent 542cfba commit 283a6a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
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
3 changes: 3 additions & 0 deletions test/validators.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ describe('Validators', () => {
'nbsp [email protected]',
'nbsp_test@te st.com',
'[email protected] m',
'"[email protected]',
'"foo"[email protected]',
'foo"bar"@gmail.com',
],
});
});
Expand Down

0 comments on commit 283a6a5

Please sign in to comment.