Skip to content

Commit 283a6a5

Browse files
authored
fix(isEmail): email starting with double quotes (#2437)
fixes #2432
1 parent 542cfba commit 283a6a5

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/lib/isEmail.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ export default function isEmail(str, options) {
109109

110110
if (options.domain_specific_validation && (lower_domain === 'gmail.com' || lower_domain === 'googlemail.com')) {
111111
/*
112-
Previously we removed dots for gmail addresses before validating.
113-
This was removed because it allows `[email protected]`
114-
to be reported as valid, but it is not.
115-
Gmail only normalizes single dots, removing them from here is pointless,
116-
should be done in normalizeEmail
112+
Previously we removed dots for gmail addresses before validating.
113+
This was removed because it allows `[email protected]`
114+
to be reported as valid, but it is not.
115+
Gmail only normalizes single dots, removing them from here is pointless,
116+
should be done in normalizeEmail
117117
*/
118118
user = user.toLowerCase();
119119

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

169-
if (user[0] === '"') {
169+
if (user[0] === '"' && user[user.length - 1] === '"') {
170170
user = user.slice(1, user.length - 1);
171171
return options.allow_utf8_local_part ?
172172
quotedEmailUserUtf8.test(user) :

test/validators.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ describe('Validators', () => {
7171
7272
'nbsp_test@te st.com',
7373
74+
75+
76+
'foo"bar"@gmail.com',
7477
],
7578
});
7679
});

0 commit comments

Comments
 (0)