Req #49576 [Opn->Asn]: Filter var for validating email is not validating emails correctly
| From: | rasmus@php.net | Date: | Fri, 02 Apr 2010 05:40:30 +0000 |
| Subject: | Req #49576 [Opn->Asn]: Filter var for validating email is not validating emails correctly | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-149267@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=49576&edit=1
ID: 49576
Updated by: rasmus@php.net
Reported by: mparkin at de-facto dot com
Summary: Filter var for validating email is not validating
emails correctly
-Status: Open
+Status: Assigned
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
Operating System: *
PHP Version: 5.*, 6
-Assigned To:
+Assigned To: rasmus
New Comment:
Finally having a look at this. Some of your cases are actually
incorrect
according to RFC3696/RFC5322
For example. IPInsteadOfDomain@127.0.0.1 is not a valid email address
according
to the RFC. IPs in an email address must be in square brackets. So it
should
be IPInsteadOfDomain@[127.0.0.1] for that one to be valid. This is
valid under
both RFC822 and RFC2822, but RFC3696 and RFC5322 updates those RFCs.
And you
can't have a port in it, so IPAndPort@127.0.0.1:25 is invalid as well,
even if
you added the square brackets. Also we do not validate domains, so your
2
examples of invalid TLDs are not relevant.
I'll have an update of the baked in regex soon, but it sounds like you
need to
update the Kohana one as well.
Previous Comments:
------------------------------------------------------------------------
[2009-09-17 08:53:51] mparkin at de-facto dot com
Description:
------------
Filter_Var does not validate emails accurately enough, and false
positives are made. The regex needs improving - the regex we are using
in kohanaphp framework (with preg_match) is more accurate.
some more reading could be done here:
http://fightingforalostcause.net/misc/2006/compare-email-regex.php
Reproduce code:
---------------
http://codepad.org/UIrhI5ep
Expected result:
----------------
All emails in $valid are valid, all emails in $invalid are invalid.
A far more accurate regex can be found here:
http://dev.kohanaphp.com/projects/kohana2/repository/entry/trunk/system/helpers/valid.php#L20
Actual result:
--------------
There are false positives and non failures.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=49576&edit=1