Req #69140 [Opn]: FILTER_VALIDATE_EMAIL should accept user@localhost

From: Date: Thu, 24 Nov 2016 07:43:39 +0000
Subject: Req #69140 [Opn]: FILTER_VALIDATE_EMAIL should accept user@localhost
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-205595@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69140&edit=1

 ID:                 69140
 Updated by:         yohgaki@php.net
 Reported by:        info at linux-web-development dot de
 Summary:            FILTER_VALIDATE_EMAIL should accept user@localhost
 Status:             Open
 Type:               Feature/Change Request
 Package:            Filter related
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

I understand there is use case for user@localhost. However, accepting user@localhost (or
user@hostnameonly) is problematic for most applications.

Therefore, there should be additional flag for it. Problems is all flags, i.e. flag is bit flag, is
used already. We can reuse some bits, though.

IMHO, current filter module's validation feature is incomplete and unusable. Instead of adding
specific rare usage, it's better to have generic and extensible validator such as
https://wiki.php.net/rfc/add_validate_functions_to_filter


Previous Comments:
------------------------------------------------------------------------
[2016-11-22 12:12:44] bugs-php-net at unikorn dot me

I'm sorry, but did you seriously just change the whole topic because you can't
differentiate between the RFCs for emails and their address format and a transport protocol for
them?

The original bug clearly stated that there are different standards-compliant email addresses that
won't work with PHPs filter_var, not only one. I'm not sure why PHP developers are this,
but out in the real world, not being standards-compliant is a bug.

------------------------------------------------------------------------
[2016-11-21 17:04:38] cmb@php.net

Related To: Bug #66553

------------------------------------------------------------------------
[2016-11-21 17:02:11] cmb@php.net

> The PHP validation is just wrong in more ways than just
> comments. e.g. the domain part could be a hostname without a
> dot, but this always comes back as false.

This is a deliberate decision to avoid issues with RFC 5321[1], so
simply changing the behavior would cause issues. Introducing a new
flag appears to be the most reasonable solution, so I'm changing
to feature request, leaving the documentation part to bug #66553.

[1] <https://github.com/php/php-src/blob/PHP-7.0.13/ext/filter/logical_filters.c#L579-L588>

------------------------------------------------------------------------
[2015-03-02 00:16:21] ppaisndud at gmail dot com

I did a bit of fixing and this could be a patch, strict to RFC 822 

https://github.com/pasindud/php-src/commit/ec209d5add25322122e10e18261f0ae5fa7a57cf

Some Issuses

RFC 822 - is obsolete in 2001 by 2822, 5322
RFC 2822 - is obsolete in 2008 by 5322,5321 (both of those also have conflicts)

------------------------------------------------------------------------
[2015-03-01 18:18:10] info at linux-web-development dot de

The docs are still not correct. The PHP validation is just wrong in more ways than just comments.
e.g. the domain part could be a hostname without a dot, but this always comes back as false. This
has real applications, e.g. under Linux when sending to [user]@localhost

There is a reason frameworks don't use this built-in function but instead resort to their own
validation for e-mails. So this function should either be clearly marked as non-RFC-compatible or
just work as one would expect it to work. Sorry, but not fixing this because it's hard to
implement is just a lame excuse. Implement it or leave it out, but don't implement some
half-working frankenvalidation.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=69140


--
Edit this bug report at https://bugs.php.net/bug.php?id=69140&edit=1


Thread (7 messages)

« previous php.bugs (#205595) next »