php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #65385 filter_var() with built in idn_to_ascii() support
Submitted: 2013-08-03 15:46 UTC Modified: 2015-06-15 23:28 UTC
Votes:3
Avg. Score:4.0 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:2 (66.7%)
From: juergen78 at gmail dot com Assigned: cmb (profile)
Status: Duplicate Package: Filter related
PHP Version: Irrelevant OS: irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: juergen78 at gmail dot com
New email:
PHP Version: OS:

 

 [2013-08-03 15:46 UTC] juergen78 at gmail dot com
Description:
------------
There are filter_var() and idn_to_ascii(). 

- filter_var('bob@example.com', FILTER_VALIDATE_EMAIL);
- idn_to_ascii()

But the filter_var('bob@example.com', FILTER_VALIDATE_EMAIL) is not able to check international Domains. So it would be eligible if filter_var() itself can intern e.g. via idn_to_ascii() convert a international Domain bevor check.

This time it is only doable with a workaround - see Below "Test Script"

Test script:
---------------
function validate_email($mail)
{
    if ( ! filter_var($mail, FILTER_VALIDATE_EMAIL) ) {
        $in = explode('@', $mail);
        $in[1] = idn_to_ascii($in[1]);
        return (bool) filter_var(join('@', $in), FILTER_VALIDATE_EMAIL);
    }

    return true;
}

$mail = "foo@müller.de";
var_dump( validate_email($mail) ); 



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-08-03 17:03 UTC] juergen78 at gmail dot com
-: j dot haus at gmx dot at +: juergen78 at gmail dot com
 [2013-08-03 17:03 UTC] juergen78 at gmail dot com
text corr.
 [2015-06-15 23:28 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Package: filter +Package: Filter related -Assigned To: +Assigned To: cmb
 [2015-06-15 23:28 UTC] cmb@php.net
Duplicate of request #39469.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 20:01:30 2024 UTC