Steps to reproduce the issue
In any layout file add the following code:
<?php
$uri = Uri::getInstance('index.php?option=com_content&var=#//:?&@\')');?>
<a href="<?php echo $uri;?>">some link</a>
Then check the link in the browser.
Expected result
The link contains special characters which are supposed to be encoded.
Otherwise the url is not functional.
Actual result
Not encoded special characters.
Even if we pass the characters encoded, those are decoded when the url is converted to string.
System information (as much as possible)
Joomla 3 and Joomla 4
Opened that to the proper repository:
joomla-framework/uri#22