From c726213680c5ac56ba510220ea09b08ce041f1ac Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 13 Apr 2021 10:03:50 +0100 Subject: [PATCH] Switch to a spec conforming email validation Regexp --- src/email.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/email.ts b/src/email.ts index 6642a51541..0476d4467c 100644 --- a/src/email.ts +++ b/src/email.ts @@ -14,7 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -const EMAIL_ADDRESS_REGEX = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i; +// Regexp based on Simpler Version from https://gist.github.com/gregseth/5582254 - matches RFC2822 +const EMAIL_ADDRESS_REGEX = new RegExp( + "^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*" + // localpart + "@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$", "i"); export function looksValid(email: string): boolean { return EMAIL_ADDRESS_REGEX.test(email);