From 3047a4f8d8ce7509846fb5b1be364bcb46347271 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Mon, 31 Jul 2023 23:04:23 +0300 Subject: [PATCH 1/3] Add 64 characters limit for the username in the emails. --- lib/CONST.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/CONST.jsx b/lib/CONST.jsx index 0faf47c1..48755396 100644 --- a/lib/CONST.jsx +++ b/lib/CONST.jsx @@ -1,6 +1,6 @@ /* eslint-disable no-useless-escape */ -const EMAIL_BASE_REGEX = "([\\w\\-\\+\\'#]+(?:\\.[\\w\\-\\'\\+]+)*@(?:[\\w\\-]+\\.)+[a-z]{2,})"; +const EMAIL_BASE_REGEX = "([\\w\\-\\+\\'#]{0,64}(?:\\.[\\w\\-\\'\\+]+)*@(?:[\\w\\-]+\\.)+[a-z]{2,})"; const MOMENT_FORMAT_STRING = 'YYYY-MM-DD'; From d72aec65632f478f5f11b2a8de537d51674effba Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Mon, 31 Jul 2023 23:04:42 +0300 Subject: [PATCH 2/3] Add a test for the change related to email regex --- __tests__/Str-test.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/__tests__/Str-test.js b/__tests__/Str-test.js index c8d1a386..fc2d290b 100644 --- a/__tests__/Str-test.js +++ b/__tests__/Str-test.js @@ -95,3 +95,11 @@ describe('Str.sanitizeURL', () => { expect(Str.sanitizeURL('HTtp://FOO.com/blah_BLAH')).toBe('http://foo.com/blah_BLAH'); }); }); + +describe('Str.isValidEmail', () => { + it('Correctly detects a valid email', () => { + expect(Str.isValidEmail('abc@gmail.com')).toBeTruthy(); + expect(Str.isValidEmail('test@gmail')).toBeFalsy(); + expect(Str.isValidEmail('usernamelongerthan64charactersshouldnotworkaccordingtorfc822whichisusedbyphp@gmail.com')).toBeFalsy(); + }); +}); From c43e0cbf88b9fd3c6889b6504d737c87f53ea6a6 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Mon, 31 Jul 2023 23:20:32 +0300 Subject: [PATCH 3/3] Update email regex to have at least 1 character in the email username --- lib/CONST.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/CONST.jsx b/lib/CONST.jsx index 48755396..4b35e75b 100644 --- a/lib/CONST.jsx +++ b/lib/CONST.jsx @@ -1,6 +1,6 @@ /* eslint-disable no-useless-escape */ -const EMAIL_BASE_REGEX = "([\\w\\-\\+\\'#]{0,64}(?:\\.[\\w\\-\\'\\+]+)*@(?:[\\w\\-]+\\.)+[a-z]{2,})"; +const EMAIL_BASE_REGEX = "([\\w\\-\\+\\'#]{1,64}(?:\\.[\\w\\-\\'\\+]+)*@(?:[\\w\\-]+\\.)+[a-z]{2,})"; const MOMENT_FORMAT_STRING = 'YYYY-MM-DD';