Open GuylainK7 opened 1 week ago
I think the following is a way to go.
--- a/system/HTTP/URI.php
+++ b/system/HTTP/URI.php
@@ -1177,7 +1177,8 @@ class URI implements Stringable
parse_str($params, $result);
foreach ($result as $key => $value) {
- $return[hex2bin($key)] = $value;
+ // Array key might be int
+ $return[hex2bin((string) $key)] = $value;
}
return $return;
PHP Version
8.2
CodeIgniter4 Version
4.5.x
CodeIgniter4 Installation Method
Composer (using
codeigniter4/appstarter
)Which operating systems have you tested for this bug?
Linux
Which server did you use?
apache
Database
MySQL 8.0.34
What happened?
After updating from CodeIgniter 4.4.8 to 4.5.4, a curl call started throwing an exception
Steps to Reproduce
try to make a curl request with the following code
Expected Output
The curl request should work if the baseURI provided is reachable
Anything else?
errorLog.txt
The problem comes from the code found in
protected function parseStr(string $query): array
since the addition ofdeclare(strict_types=1);
in the file/vendor/codeigniter4/framework/system/HTTP/URI.php
A parameter namedstartAt
once hexed gives a hex value of73746172744174
which is not interpreted as a string in the foreach found on line 1179One way to avoid this problem is to fill the url parameter correctly with the url instead of passing through the options ex:
$curl->request('GET', 'http://localhost:8080?startAt=0&limit=10', []);
A possible fix would be to cast
$key
as a string on line 1180$return[hex2bin((string)$key)] = $value;
Another would be to remove thedeclare(strict_types=1);
(not recommended)