#50158 [Ver]: FILTER_VALIDATE_EMAIL fails with valid addresses containing = or ?
| From: | pierrick@php.net | Date: | Sat, 14 Nov 2009 17:25:03 +0000 |
| Subject: | #50158 [Ver]: FILTER_VALIDATE_EMAIL fails with valid addresses containing = or ? | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-144614@lists.php.net to get a copy of this message | ||
ID: 50158
Updated by: pierrick@php.net
Reported By: andrew dot nicols at luns dot net dot uk
Status: Verified
Bug Type: Filter related
Operating System: *
PHP Version: 5.*, 6
Assigned To: pierrick
New Comment:
Patch available at:
http://www.adoy.net/php/50158.patch
This patch add = and ? to the local-part validation according to
RFC2822
Previous Comments:
------------------------------------------------------------------------
[2009-11-12 17:12:50] jani@php.net
Quick check to the regexp used shows these are missing from allowed
part in it: = ?
------------------------------------------------------------------------
[2009-11-12 17:07:56] jani@php.net
Yes, = is valid. And also any of these too:
! $ & * - = ^ ` | ~ # % ' + / ? _ { }
------------------------------------------------------------------------
[2009-11-12 14:57:16] andrew dot nicols at luns dot net dot uk
Copy/paste bug on my behalf. The expected result is:
string(21) "test=mail@example.com"
string(21) "test-mail@example.com"
string(21) "test+mail@example.com"
------------------------------------------------------------------------
[2009-11-12 14:56:05] andrew dot nicols at luns dot net dot uk
Description:
------------
The filter_var function, when used with FILTER_VALIDATE_EMAIL marks an
email address with an = in it as invalid.
According to RFCs 822, 2822 and 5322, = is a valid component to the
local-part of an e-mail address.
Reproduce code:
---------------
<?php
$email_address = "test=mail@example.com";
var_dump(filter_var($email_address, FILTER_VALIDATE_EMAIL));
$email_address = "test-mail@example.com";
var_dump(filter_var($email_address, FILTER_VALIDATE_EMAIL));
$email_address = "test+mail@example.com";
var_dump(filter_var($email_address, FILTER_VALIDATE_EMAIL));
?>
Expected result:
----------------
string(21) "test-mail@example.com"
string(21) "test-mail@example.com"
string(21) "test+mail@example.com"
Actual result:
--------------
bool(false)
string(21) "test+mail@example.com"
string(21) "test+mail@example.com"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50158&edit=1