Skip to content

Commit

Permalink
Fix RFC3986 normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Dec 27, 2024
1 parent 7a3f294 commit cd2ea2d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 deletions.
11 changes: 1 addition & 10 deletions Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
use League\Uri\Exceptions\MissingFeature;
use League\Uri\Exceptions\SyntaxError;
use League\Uri\Idna\Converter as IdnaConverter;
use League\Uri\IPv4\Converter as IPv4Converter;
use League\Uri\IPv6\Converter as IPv6Converter;
use League\Uri\UriTemplate\TemplateCanNotBeExpanded;
use Psr\Http\Message\UriInterface as Psr7UriInterface;
Expand Down Expand Up @@ -1013,15 +1012,7 @@ private function normalizeHost(): ?string
return null;
}

$host = $this->host;
$hostIp = IPv4Converter::fromEnvironment()->toDecimal($host);

return IdnaConverter::toUnicode((string)IPv6Converter::compress(match (true) {
'' === $host,
null === $hostIp,
$host === $hostIp => $host,
default => $hostIp,
}))->domain();
return IdnaConverter::toUnicode((string)IPv6Converter::compress($this->host))->domain();
}

/**
Expand Down
8 changes: 0 additions & 8 deletions UriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -760,14 +760,6 @@ public static function getOriginProvider(): array
'uri' => Uri::new('blob:https://mozilla.org:443/'),
'expectedOrigin' => 'https://mozilla.org',
],
'normalized ipv4' => [
'uri' => 'https://0:443/',
'expectedOrigin' => 'https://0.0.0.0',
],
'normalized ipv4 with object' => [
'uri' => Uri::new('https://0:443/'),
'expectedOrigin' => 'https://0.0.0.0',
],
'compressed ipv6' => [
'uri' => 'https://[1050:0000:0000:0000:0005:0000:300c:326b]:443/',
'expectedOrigin' => 'https://[1050::5:0:300c:326b]',
Expand Down

0 comments on commit cd2ea2d

Please sign in to comment.