Skip to content

Commit

Permalink
fix #150
Browse files Browse the repository at this point in the history
  • Loading branch information
ntzm committed Jan 14, 2020
1 parent b2f127d commit 0a52016
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/UriString.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,11 @@ private static function filterRegisteredName(string $host): string
// @codeCoverageIgnoreEnd

$retval = idn_to_ascii($formatted_host, 0, INTL_IDNA_VARIANT_UTS46, $arr);

if ($arr === []) {
throw new SyntaxError(sprintf('Host `%s` is not a valid IDN host', $host));
}

if (0 !== $arr['errors']) {
throw new SyntaxError(sprintf('Host `%s` is not a valid IDN host : %s', $host, self::getIDNAErrors($arr['errors'])));
}
Expand Down
1 change: 1 addition & 0 deletions tests/UriStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ public function invalidUriProvider(): array
'invalid Host with fullwith (1)' => ['http://%00.com'],
'invalid host with fullwidth escaped' => ['http://%ef%bc%85%ef%bc%94%ef%bc%91.com],'],
'invalid pseudo IDN to ASCII string' => ['http://xn--3/foo.'],
'invalid IDN' => ['//:�@�����������������������������������������������������������������������������������������/'],
];
}

Expand Down

0 comments on commit 0a52016

Please sign in to comment.