|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-03-29 17:51 UTC] cmb@php.net
-Package: *General Issues
+Package: Filter related
[2021-08-05 17:26 UTC] git@php.net
[2021-08-05 17:26 UTC] git@php.net
-Status: Open
+Status: Closed
[2021-08-06 01:24 UTC] git@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 08:00:01 2025 UTC |
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