Skip to content

Commit

Permalink
Make sure that IDNA's toASCII operation does not return an empty string.
Browse files Browse the repository at this point in the history
Addresses whatwg/url#497
  • Loading branch information
TRowbotham committed May 10, 2020
1 parent a70fc1c commit 65051af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- `URLSearchParams::sort()` now correctly sorts by code units instead of trying to fake it using code points.
- Null bytes are now percent encoded in fragments instead of being ignored per [whatwg/url#440](https://github.com/whatwg/url/issues/440).
- The host of URLs with special schemes can no longer be an empty string per [whatwg/url#497](https://github.com/whatwg/url/pull/497).

### Fixed

Expand Down
9 changes: 8 additions & 1 deletion src/Component/Host/HostParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ private function domainToAscii(string $domain, bool $beStrict = false): StringHo
}

try {
return new StringHost(IDNA::toAscii($domain, $flags));
$result = IDNA::toAscii($domain, $flags);

if ($result === '') {
// Validation error.
throw new IDNATransformException();
}

return new StringHost($result);
} catch (IDNATransformException $e) {
// Validation error.
throw $e;
Expand Down

0 comments on commit 65051af

Please sign in to comment.