[php-src] Issue #21427: \Uri\Rfc3986\Uri does not handle some non-encoded characters (`@`, `[`)
[email protected] (earthiverse)
| Newsgroups | php.bugs |
|---|---|
| Message-ID | <41qS07WXKWvLnI9CkGwnwAuRddf0MZ26PM7FwVMHm1g@main.internal.php.net> |
Issue: https://github.com/php/php-src/issues/21427
Author: earthiverse
### Description
The following code:
```sh
var_dump(new \Uri\Rfc3986\Uri("http://media-store.localhost/img/store/31/bc/0ef8ebbc4035984ef59aa595cf4f7ee8d068/%C3%89t%C3%89@%C3%89b%C3%89g%C3%89o%C3%85[%C3%89K%C3%85[%C3%87Q.jpg"));
```
Resulted in this output:
```
PHP Warning: Uncaught Uri\InvalidUriException: The specified URI is malformed
```
But I expected this output instead:
```
class Uri\Rfc3986\Uri#2 (8) {
public $scheme =>
string(4) "http"
public $username =>
NULL
public $password =>
NULL
public $host =>
string(21) "media-store.localhost"
public $port =>
NULL
public $path =>
string(118) "/img/store/31/bc/0ef8ebbc4035984ef59aa595cf4f7ee8d068/%C3%89t%C3%89@%C3%89b%C3%89g%C3%89o%C3%85[%C3%89K%C3%85[%C3%87Q.jpg"
public $query =>
NULL
public $fragment =>
NULL
}
```
---
I'm not too sure about RFC 3986, but I copied that URL straight from my browser's URL, and it didn't encode the `@` or `[` characters when I copied it. If I percent-encode those, it parses OK.
https://en.wikipedia.org/wiki/Percent-encoding#Reserved_characters says "reserved characters that have no reserved purpose in a particular context may also be percent-encoded but are not semantically different from those that are not."
### PHP Version
```plain
PHP 8.5.3 (cli) (built: Feb 10 2026 18:25:51) (NTS)
Copyright (c) The PHP Group
Built by Shivam Mathur
Zend Engine v4.5.3, Copyright (c) Zend Technologies
with Xdebug v3.5.1, Copyright (c) 2002-2026, by Derick Rethans
with Zend OPcache v8.5.3, Copyright (c), by Zend Technologies
```
### Operating System
MacOS Tahoe 26.3.1