Keats / validator

Simple validation for Rust structs
MIT License
1.97k stars 141 forks source link

Email with UTF-8 characters #275

Open 1oglop1 opened 10 months ago

1oglop1 commented 10 months ago

Hi, I was comparing this crate with email_address crate

And I have an email with a controversial character � - https://en.wikipedia.org/wiki/Specials_(Unicode_block) Then email_address and validator do not agree if it is valid or not abc�def@example.com

let email = "abc�def@example.com";
EmailAddress::from_str(email).is_ok(); // true
validator::validate_email(email);  // false

According to RFC6531 - UTF-8 characters should be allowed in the email however, it is often not very practical.

Perhaps the solution could be adding some parse options to the email validator. Probably the best thing for the community would be to have just one crate for email validation and cooperation between email_address and validator.

Refs:

Keats commented 10 months ago

Our validation is very simple: https://github.com/Keats/validator/blob/master/validator/src/validation/email.rs#L8-L18 we just use whatever the HTML spec allows. So it will reject potentially valid email addresses as indicated in a comment in those lines.