|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #71282 Documentation is invalid for FILTER_VALIDATE_EMAIL
Submitted: 2016-01-05 12:58 UTC Modified: 2018-03-29 17:51 UTC
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: sebastian dot piskorski at gmail dot com Assigned:
Status: Open Package: Filter related
PHP Version: 5.6.16 OS: Xubuntu
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-01-05 12:58 UTC] sebastian dot piskorski at gmail dot com
Documatation states that e-mail address validated "against the syntax in RFC 822, with the exceptions that comments and whitespace folding are not supported.", which is not true.

Filter validates only against addr-spec specification part. Because such address is invalid "Test Example <>". Another example is "test@localhost" which should be valid, brcause RFC 822 doesn't fore address to have a .domain part.

All exceptions should be mentioned, not only current two.

Test script:

$emails = array(
    'Test Example <>',

foreach ($emails as $email) {
    echo (filter_var($email, FILTER_VALIDATE_EMAIL)) ? 
        "[+] Email '$email' is valid\n" : 
        "[-] Email '$email' is NOT valid\n";

Expected result:
[+] Email 'Test Example <>' is valid
[+] Email 'test@localhost' is valid
[+] Email '' is valid

Actual result:
[-] Email 'Test Example <>' is NOT valid
[-] Email 'test@localhost' is NOT valid
[+] Email '' is valid


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-03-29 17:51 UTC]
-Package: *General Issues +Package: Filter related
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Apr 19 09:01:24 2021 UTC