Bug #53395 [Bgs]: FILTER_VALIDATE_EMAIL return false on valid emails
| From: | rasmus@php.net | Date: | Thu, 25 Nov 2010 05:41:31 +0000 |
| Subject: | Bug #53395 [Bgs]: FILTER_VALIDATE_EMAIL return false on valid emails | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-156433@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53395&edit=1
ID: 53395
Updated by: rasmus@php.net
Reported by: edanpr at gmail dot com
Summary: FILTER_VALIDATE_EMAIL return false on valid emails
Status: Bogus
Type: Bug
Package: Filter related
Operating System: debian
PHP Version: 5.3.3
Block user comment: N
Private report: N
New Comment:
This comes back to whether we filter according to spec or we filter
according to
real-world cases that go against the spec. The problem with the latter
is that it
is not a finite problem. If we go by the spec we can simply follow the
spec and
we are done. But yes, you are right, there are domains out there that
are not
legal according to the RFCs but have still been issued for whatever
reason. 2
hyphens is definitely not valid in non-IDN domain names.
Previous Comments:
------------------------------------------------------------------------
[2010-11-25 04:39:27] edanpr at gmail dot com
Ok, 2 dots is wrong, but double dash is still a valid domain which means
users can have email there.
a--b.com - real domain
h--t.com - real domain
------------------------------------------------------------------------
[2010-11-25 04:06:44] aharvey@php.net
filter_var() is right in both cases here: domain names can only
include consecutive hyphens when being used for internationalised
domains (which implies that the name is of the form xn--XXX), and the
local part of an e-mail address can't include consecutive dots, per
the grammar in RFC 5322.
------------------------------------------------------------------------
[2010-11-24 12:58:10] edanpr at gmail dot com
Description:
------------
In php 5.3.3 using filter_var to validate email (FILTER_VALIDATE_EMAIL)
that got more than one period (.) or dash (-) results in error while in
5.3.2 it didn't.
test@h--t.com will return false on 5.3.3 and true on 5.3.2
t..est@test.com will return false on 5.3.3 and true on 5.3.2
Test script:
---------------
<?
$adr1 = 't..est@test.com';
$adr2 = 'test@h--t.com';
var_dump(filter_var($adr1, FILTER_VALIDATE_EMAIL));
var_dump(filter_var($adr2, FILTER_VALIDATE_EMAIL));
Expected result:
----------------
string(15) "t..est@test.com"
string(13) "test@h--t.com"
Actual result:
--------------
bool(false)
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53395&edit=1