php.net |  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
Votes:2
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
Description:
------------
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 <test@example.com>". 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:
---------------
<?php

$emails = array(
    'Test Example <test@example.com>',
    'test@localhost',
    'test@localhost.com'
);

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 <test@example.com>' is valid
[+] Email 'test@localhost' is valid
[+] Email 'test@localhost.com' is valid

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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-03-29 17:51 UTC] cmb@php.net
-Package: *General Issues +Package: Filter related
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Jun 24 09:01:26 2019 UTC