diff --git a/src/lib/isEmail.js b/src/lib/isEmail.js index abe465052..ce5b732c1 100644 --- a/src/lib/isEmail.js +++ b/src/lib/isEmail.js @@ -168,6 +168,14 @@ export default function isEmail(str, options) { if (user[0] === '"' && user[user.length - 1] === '"') { user = user.slice(1, user.length - 1); + + if ( + !options.allow_utf8_local_part && + Buffer.byteLength(user, 'utf8') !== user.length + ) { + return false; + } + return options.allow_utf8_local_part ? quotedEmailUserUtf8.test(user) : quotedEmailUser.test(user); diff --git a/test/validators.test.js b/test/validators.test.js index 9bd00d6ec..b5971dc59 100644 --- a/test/validators.test.js +++ b/test/validators.test.js @@ -134,6 +134,8 @@ describe('Validators', () => { 'z@co.c', 'tüst@invalid.com', 'nbsp test@test.com', + '"tüst"@example.com', + '"m端ller"@example.com', ], }); });