Skip to content

Commit

Permalink
Support uppercase IPv6 addresses in URI
Browse files Browse the repository at this point in the history
RFC8187 implies that the HEXDIG values that compose an IP-Literal
substring (IPv6 is a special case of IP-Literal) can contain both
lowercase and uppercase characters for the non-numeric part. As
a consequence, all characters in [0-9a-fA-f] are valid in an IPv6
literal address as found in the URI.

References:
* https://datatracker.ietf.org/doc/html/rfc5234
* https://datatracker.ietf.org/doc/html/rfc8187

Signed-off-by: Emmanuel Deloget <[email protected]>
  • Loading branch information
emmanuel-deloget committed Jan 22, 2025
1 parent a70f5c9 commit 3b61982
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private static function parse(string $url)
{
// If IPv6
$prefix = '';
if (preg_match('%^(.*://\[[0-9:a-f]+\])(.*?)$%', $url, $matches)) {
if (preg_match('%^(.*://\[[0-9:a-fA-F]+\])(.*?)$%', $url, $matches)) {
/** @var array{0:string, 1:string, 2:string} $matches */
$prefix = $matches[1];
$url = $matches[2];
Expand Down

0 comments on commit 3b61982

Please sign in to comment.