Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unclear documentation about targeted RFC. #186

Closed
stefanotorresi opened this issue Nov 27, 2018 · 3 comments
Closed

Unclear documentation about targeted RFC. #186

stefanotorresi opened this issue Nov 27, 2018 · 3 comments

Comments

@stefanotorresi
Copy link

stefanotorresi commented Nov 27, 2018

Hello there,

It is unclear to me what RFC is being targeted here. From a glance at the code, it looks like 5321/5322 are the reference.
If that's the case, why are non-ASCII characters allowed in the local-part of the address when using the provided RFCValidation class? Those are only permitted by 6531.
Or am I missing something?

egulias added a commit that referenced this issue Dec 3, 2018
@egulias
Copy link
Owner

egulias commented Dec 3, 2018

Hi @stefanotorresi !
Yes, it was not stated. Just did a push with the information: https://github.com/egulias/EmailValidator/blob/master/README.md#suported-rfcs

@stefanotorresi
Copy link
Author

stefanotorresi commented Dec 3, 2018

Thanks for the update!

Would you be interested in a PR that proposes different validation classes for different RFCs? My main use-case is that I'd like to validate against just 5321/5322, not 6531; i.e. the validator wouldn't allow non-ASCII characters. I think it should be easy enough to add some more warnings to the parser, what do you think?

The main reason behind this is that there are some very popular mail services like Mailchimp/Mandrill that still don't support 6531.

@egulias
Copy link
Owner

egulias commented Dec 4, 2018

Would be interesting of course.
However adding warnings for the sake of the different RFC's would clutter the code.
Also you need to check for other restrictions (e.g does RFC5321/5322 allow for comments? parenthesis? ) besides the ASCII ones.

For ASCII alone we could do something like:

  1. Make EmailLexer and interface and expose the dependency in EmailValidator. It has to be done backward compatible, with the standard lexer by default.
  2. Implement RFC532xEmailLexer removing utf8 chars and testing for ASCII alone (see here)

With that you could do this

use Egulias\EmailValidator\RFC532xEmailLexer;
use Egulias\EmailValidator\EmailValidator;
use Egulias\EmailValidator\Validation\RFCValidation;

$validator = new EmailValidator(new RFC532xEmailLexer());
$validator->isValid("examplë@example.com", new RFCValidation()); //false

for a validation closer to RFC532x , you'd have to re-implement Local and Domain part parsers.

@egulias egulias closed this as completed Apr 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants