ryancramerdesign / ProcessWire

Our repository has moved to https://github.com/processwire – please head there for the latest version.
https://processwire.com
Other
727 stars 201 forks source link

$sanitizer->email does not allow local domain name without TLD #1292

Open dsdsdsdsdsds opened 9 years ago

dsdsdsdsdsds commented 9 years ago

If sanitizing an email address like admin@mailserver with $sanitizer->email, a blank string is returned (=invalid email). However, it is actually a valid format according to this list.

teppokoivula commented 9 years ago

This was discussed at the forums a long(-ish) time ago, though probably in relation to the Email field. Can't find that thread now, but I believe one question was that even if something like me@localhost is a valid email address, should it be (by default) valid email address in ProcessWire?

When used in a public-facing situation, you usually don't want users posting email addresses like that. It's more likely that "john.doe@example" would be a misspelling of something like "john.doe@example.com" than a real and working (public) email address.

On the other hand, in some cases (intranets, certain types of applications, otherwise limited scope) this might be very important. So, perhaps some way to define whether or not "local" addresses are valid..?

Another thing to note is that Sanitizer uses PHP's FILTER_VALIDATE_EMAIL to validate emails. This won't work for non-TLD email addresses, and some other "non-typical" cases, so the validation method would have to change quite a bit to accommodate for this.