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

RFC: is & valid in a domain? #7

Closed
ben-manes opened this issue Nov 18, 2016 · 3 comments
Closed

RFC: is & valid in a domain? #7

ben-manes opened this issue Nov 18, 2016 · 3 comments

Comments

@ben-manes
Copy link

Running a migration of and a user had registered with the domain pg&e.com. This passed my scrubbing using isValid(email) but failed during digestion due to json schema validator rejecting it. Switching to isValid(email, EmailAddressCriteria.DEFAULT) rejects the address as well. Skimming over the RFC I couldn't tell if this was allowed and why & was accepted.

@chconnor
Copy link
Contributor

If you look here: https://tools.ietf.org/html/rfc5322#page-13 ... you'll see that the domain part of an email address is allowed "&" and all sorts of other stuff (the "atext" definition). That makes it a "valid" email address, even though it is not actually a valid domain and you can't deliver to it.

EmailAddressCriteria.DEFAULT disallows "ALLOW_DOMAIN_LITERALS", which is why it rejects as you expect, and apparently isValid() doesn't actually use DEFAULT by default.

@bbottema -- perhaps "DEFAULT" is a misnomer here, since the default of isValid() is actually RFC_COMPLIANT, or perhaps the default for isValid() should actually be changed to DEFAULT. :-)

https://github.com/bbottema/email-rfc2822-validator/blob/master/src/main/java/org/hazlewood/connor/bottema/emailaddress/EmailAddressValidator.java#L117

@bbottema
Copy link
Owner

Agreed, the naming is a little confusing. I will update this.

@bbottema
Copy link
Owner

Released in v1.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants