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

[email protected] ("asfrdgtfgjh322 at gmail dot com") Fri, 30 Jun 2023 10:09:44 +0000
Newsgroups php.doc.bugs
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=80922&edit=1

 ID:                 80922
 Comment by:         asfrdgtfgjh322 at gmail 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:            I18N and L10N related
 Operating System:   FreeBSD
 PHP Version:        7.4.16
 Block user comment: N
 Private report:     N

 New Comment:

(https://php.net)(https://www.marykayintouch.website/)

That was so amazing.


Previous Comments:
------------------------------------------------------------------------
[2023-01-23 09:54:09] jules dot bernable at gmail dot com

RFC3986 section 3.2.2[1] clearly states that the host component of a URI is case-insensitive.

The idn_to_ascii function uses ICU's uidna_nameToASCII, whose purpose is to encode domain names in the format defined in RFC5890[2], to allow robust case-insensitive comparison of IDNs.

Therefore, I think this bug is invalid.

[1] www.rfc-editor.org/rfc/rfc3986#section-3.2.2
[2] www.rfc-editor.org/rfc/rfc5890

------------------------------------------------------------------------
[2021-04-06 20:17:50] JunkYardMail1 at Frontier dot com

<?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
}
?>

------------------------------------------------------------------------
[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] [email protected]

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