FILTER_VALIDATE_EMAIL fails with valid addresses containing = or ?
| Bug #50158 | FILTER_VALIDATE_EMAIL fails with valid addresses containing = or ? | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2009-11-12 14:56 UTC | Modified: | 2009-11-15 16:53 UTC |
|
||||||||||
| From: | andrew dot nicols at luns dot net dot uk | Assigned: | pierrick (profile) | |||||||||||
| Status: | Closed | Package: | Filter related | |||||||||||
| PHP Version: | 5.*, 6 | OS: | * | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2009-11-12 14:56 UTC] 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"
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2009-11-12 14:57 UTC] andrew dot nicols at luns dot net dot uk
[2009-11-12 17:07 UTC] jani@php.net
Yes, = is valid. And also any of these too: ! $ & * - = ^ ` | ~ # % ' + / ? _ { }[2009-11-12 17:12 UTC] jani@php.net
[2009-11-15 16:53 UTC] felipe@php.net