|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2021-03-31 01:23 UTC] JunkYardMail1 at Frontier dot com
Description: ------------ --- From manual page: https://php.net/function.idn-to-ascii --- "This function converts a Unicode domain name to an IDNA ASCII-compatible format." Clearly 'My.Domain.Example.com' is not a "Unicode domain name" and thus it should not be altered. But it is altered. It is forced to lower case. idn_to_ascii() and idn_to_utf8() functions force domain names to lower case. Even non IDN domain names are forced to lower case. Domain names are not case sensitive and thus their case should not be altered from what is passed to the functions. Case should be retained as it is provided. Test script: --------------- <?php echo 'Non IDN:' . "\n"; echo 'idn_to_ascii(\'My.Domain.Example.com\');' . "\n"; echo ' Expected result: My.Domain.Example.com' . "\n"; echo ' Actual result: ' . idn_to_ascii('My.Domain.Example.com') . "\n\n"; echo 'idn_to_utf8(\'My.Domain.Example.com\');' . "\n"; echo ' Expected result: My.Domain.Example.com' . "\n"; echo ' Actual result: ' . idn_to_utf8('My.Domain.Example.com') . "\n\n"; echo 'IDN:' . "\n"; echo 'idn_to_ascii(\'Täst.de\');' . "\n"; echo ' Expected result: xn--Tst-qla.de' . "\n"; echo ' Actual result: ' . idn_to_ascii('Täst.de') . "\n\n"; echo 'idn_to_utf8(\'xn--Tst-qla.de\');' . "\n"; echo ' Expected result: Täst.de' . "\n"; echo ' Actual result: ' . idn_to_utf8('xn--Tst-qla.de') . "\n\n"; ?> Expected result: ---------------- # Non IDN: My.Domain.Example.com My.Domain.Example.com # IDN: xn--Tst-qla.de Täst.de Actual result: -------------- # Non IDN: my.domain.example.com my.domain.example.com # IDN: xn--tst-qla.de täst.de PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 21:00:01 2025 UTC |
<?php // This works to prevent forcing lowercase of ASCII domain names. // But not does not work to prevent forcing lowercase of Unicode domain names. if (($idn = idn_to_ascii($domain_name)) === strtolower($domain_name)) { // Use the original $domain_name } else { // Use the converted $idn } ?>