php / php/php-src

ext/uri: RFC 3986 IPv6 handling is inconsistent

Open
#22,618 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Extension: uri Status: Verified
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

The following code:

<?php
$u = new Uri\Rfc3986\Uri("http://[::0:0A]/");
var_dump($u->getRawHost());
var_dump($u->getHost());
var_dump($u->toRawString());
var_dump($u->toString());

Resulted in this output:

string(8) "[::0:0A]"
string(8) "[::0:0a]"
string(49) "http://[0000:0000:0000:0000:0000:0000:0000:000a]/"
string(49) "http://[0000:0000:0000:0000:0000:0000:0000:000a]/"

But I expected this output instead:

string(8) "[::0:0A]"
string(8) "[0000:0000:0000:0000:0000:0000:0000:000a]"
string(49) "http://[::0:0A]/"
string(49) "http://[0000:0000:0000:0000:0000:0000:0000:000a]/"

Alternatively I might expect this output:

string(8) "[::0:0A]"
string(8) "[::a]"
string(49) "http://[::0:0A]/"
string(49) "http://[::a]/"
PHP Version
PHP 8.5.8 (cli) (built: Jul  1 2026 16:35:50) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.5.8, Copyright (c) Zend Technologies
    with Zend OPcache v8.5.8, Copyright (c), by Zend Technologies
Operating System

Arch Linux

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in ext/uri and reproduce the reported Uri Rfc3986 IPv6 example, comparing getRawHost(), getHost(), toRawString(), and toString(). Check the RFC 3986 handling and existing tests for IPv6 normalization; done means the chosen normalization behavior is consistent across these methods and covered by regression tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.