validatorjs / validator.js

String validation
MIT License
23.12k stars 2.31k forks source link

Email Validator issue for double quotes and special characters #2438

Open code0emperor opened 3 months ago

code0emperor commented 3 months ago

For the isEmail function, some emails like "example*."@gmail.com gets accepted due to the given below function

if(user[0] === '"' && user[user.length - 1] === '"') {
    user = user.slice(1, user.length - 1);
    return options.allow_utf8_local_part ?
      quotedEmailUserUtf8.test(user) :
      quotedEmailUser.test(user);
  }

For a valid mail, charaters like '*' and '.' should not be accepted, even when enclosed within double quotes (they should only allow some special characters and spaces). So I think the quotedEmailUserUtf8 regEx needs to be checked, but I am not sure.

Vinayak-Nevge commented 3 months ago

heyy!! i want to work on this issue can i start working on it ?

code0emperor commented 3 months ago

Go ahead

mathewalexKerala commented 2 months ago

is anyone working on this ? If not , can I ?

gshpychka commented 2 months ago

* and . are allowed in email addresses. If quoted, a . character is also allowed as the last character of the local part: https://en.wikipedia.org/wiki/Email_address#Local-part

To sum up: "example*."@gmail.com is a valid email address.

mishrasushant101 commented 1 month ago

hey @code0emperor allow me to fix this

gshpychka commented 1 month ago

hey @code0emperor allow me to fix this

this isn't a bug, though, the email address is valid. the library does have gmail-specific rules - set domain_specific_validation to true in the options to enable those.