From c7a0c3b8cb08a51f74d9f3b4a93112523a2f40db Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 7 Jan 2026 23:08:57 +0530 Subject: [PATCH] Fix isEmail rejecting UTF-8 in quoted local part when disabled --- src/lib/isEmail.js | 8 ++++++++ test/validators.test.js | 2 ++ 2 files changed, 10 insertions(+) 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', ], }); });