Bug #80855 [Nab]: FILTER_VALIDATE_DOMAIN does not recognize emoji TLDs with FILTER_FLAG_HOSTNAME
| From: | requinix@php.net | Date: | Thu, 11 Mar 2021 20:32:20 +0000 |
| Subject: | Bug #80855 [Nab]: FILTER_VALIDATE_DOMAIN does not recognize emoji TLDs with FILTER_FLAG_HOSTNAME | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-232661@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80855&edit=1
ID: 80855
Updated by: requinix@php.net
Reported by: vijaycs85 at gmail dot com
Summary: FILTER_VALIDATE_DOMAIN does not recognize emoji TLDs
with FILTER_FLAG_HOSTNAME
Status: Not a bug
Type: Bug
Package: Filter related
Operating System: OSX
PHP Version: 7.4.16
Block user comment: N
Private report: N
New Comment:
Or don't use the HOSTNAME flag.
$domain_name = 'â¡.kz';
$is_valid = filter_var($domain_name, FILTER_VALIDATE_DOMAIN);
Previous Comments:
------------------------------------------------------------------------
[2021-03-11 20:29:30] vijaycs85 at gmail dot com
Just for future reference, the below code provides the expected result.
$domain_name = 'â¡.kz';
$is_valid = filter_var(idn_to_ascii($domain_name), FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME);
var_dump($is_valid);
Output
string(10) "xn--57h.kz"
------------------------------------------------------------------------
[2021-03-11 20:22:14] vijaycs85 at gmail dot com
>Note that â¡.kz must be converted to punycode, ie. xn--57h.kz. That would be considered
>valid with the HOSTNAME flag.
Thanks for your quick reply and clarification.
------------------------------------------------------------------------
[2021-03-11 20:10:08] requinix@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
https://www.php.net/manual/en/filter.filters.validate.php
> Optional flag FILTER_FLAG_HOSTNAME adds ability to specifically validate
> hostnames (they must start with an alphanumeric character and contain only
> alphanumerics or hyphens).
Note that â¡.kz must be converted to punycode, ie. xn--57h.kz. That would be considered valid
with the HOSTNAME flag.
------------------------------------------------------------------------
[2021-03-11 19:54:24] vijaycs85 at gmail dot com
Description:
------------
There are some countries that allow Top Level Domains(TLDs) with emoji and the filter_var does not
recognize them.
Reference:
https://tinyprojects.dev/projects/mailoji
Test script:
---------------
$domain_name = 'â¡.kz';
$is_valid = filter_var($domain_name, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME);
var_dump($is_valid);
Expected result:
----------------
string(4) "â¡.kz"
Actual result:
--------------
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80855&edit=1