Bug: curl request crashes with params that give an int once hexed #9193
Labels
bug
Verified issues on the current code behavior or pull requests that will fix them
good first issue
Good for newcomers
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 named
startAt
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 the
declare(strict_types=1);
(not recommended)The text was updated successfully, but these errors were encountered: