Doc #80922 [Com]: Domain names are not case sensitive and should be handled accordingly

From: Date: Tue, 06 Apr 2021 20:17:50 +0000
Subject: Doc #80922 [Com]: Domain names are not case sensitive and should be handled accordingly
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-18690@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80922&edit=1 ID: 80922 Comment by: JunkYardMail1 at Frontier dot com Reported by: JunkYardMail1 at Frontier dot com Summary: Domain names are not case sensitive and should be handled accordingly Status: Verified Type: Documentation Problem Package: idn Operating System: FreeBSD PHP Version: 7.4.16 Block user comment: N Private report: N New Comment: <?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 } ?> Previous Comments: ------------------------------------------------------------------------ [2021-04-06 19:31:48] JunkYardMail1 at Frontier dot com The issue is broader than just not passing ASCII domain names. It also affects unicode domain names. These need to be converted to ASCII IDN for DNS usage. But should retain their original case as that is what the human input intended, as these are sometimes stored and redisplayed for human consumption as the ASCII IDN or as the original unicode, and should be presented case unchanged. ------------------------------------------------------------------------ [2021-04-06 10:33:35] cmb@php.net idn_to_ascii() is a relatively simple wrapper of uidna_nameToASCII_UTF8(), which is documented[1] as: | Converts a whole domain name into its ASCII form for DNS lookup. So the PHP documentation isn't quite right. The fact that the function returns the lower cased domain name, is just part of the normalization. I don't think it makes sense to change that behavior; if you don't want the lower casing for ASCII domain names, just don't pass these to idn_to_ascii(). [1] <https://unicode-org.github.io/icu-docs/apidoc/dev/icu4c/uidna_8h.html#aac0ee59298161bde6220f59927249f21> ------------------------------------------------------------------------ [2021-03-31 01:23:19] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80922&edit=1

« previous php.doc.bugs (#18690) next »