Description
PHP Version
8.2
CodeIgniter4 Version
4.4.6
CodeIgniter4 Installation Method
Composer (as dependency to an existing project)
Which operating systems have you tested for this bug?
Linux
Which server did you use?
apache
Database
No response
What happened?
In the process of upgrading from CI3 -> 4, I encountered a problem with a view()
that uses a fairly complex $data
structure including &references between elements. Even though the view()
helper calls setData()
with $context = 'raw'
, this still ends up in infinite recursion because esc()
iterates through the fields of the array and calls esc(..., 'raw')
on them. This whole operation is completely unnecessary because in the end it does not escape anything. However, because of the self-references, this walking of the array ends up in infinite recursion.
The esc()
function should return $data
immediately in the case of 'raw'. There's no need to walk the whole array tree just to build it anew.
Steps to Reproduce
A non-realistic example, just to illustrate the point:
$data = ['key' => []];
$data['key']['recur'] = &$data;
esc($data, 'raw');
Expected Output
The exact same $data array, without iterating its values.
Anything else?
No response