Skip to content

Commit

Permalink
Introduce breaking test for unicode hostnames
Browse files Browse the repository at this point in the history
Using an old ICANN test domain name for internationalized domain names,
hopefully not clashing with anything that actually exists. Systems that
use a C or POSIX locale seem unable to reproduce this, so try to set a
more common locale on these.

Continuation of #131.
  • Loading branch information
Zegnat committed Oct 22, 2019
1 parent 55ff6b7 commit 487c133
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/UriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,23 @@ public function testHostIsNormalizedToLowercase()
$this->assertSame('//example.com', (string) $uri);
}

public function testHostNormalizationLeavesUnicodeIntact()
{
$resetLocale = false;
if (\in_array($currentLocale = \setlocale(\LC_CTYPE, '0'), ['POSIX', 'C'])) {
$resetLocale = \setlocale(\LC_CTYPE, ['en_US.UTF-8', 'en_US.US-ASCII', 'en_US']);
}

$testDomain = 'παράδειγμα.δοκιμή';
$uri = (new Uri())->withHost($testDomain);
$this->assertSame($testDomain, $uri->getHost());
$this->assertSame('//' . $testDomain, (string) $uri);

if (false !== $resetLocale) {
\setlocale(\LC_CTYPE, $currentLocale);
}
}

public function testPortIsNullIfStandardPortForScheme()
{
// HTTPS standard port
Expand Down

0 comments on commit 487c133

Please sign in to comment.