codeigniter4 / CodeIgniter4

Open Source PHP Framework (originally from EllisLab)
https://codeigniter.com/
MIT License
5.3k stars 1.89k forks source link

Bug: Parser - Replacements happening even if key does not fully matches { value } #3825

Closed eSkiSo closed 3 years ago

eSkiSo commented 3 years ago

Describe the bug If a key of data array contains the start of the next keys, all of the replacements from then on will be done with the value of this first key, even it not fully matched.

CodeIgniter 4 version 4.0.4 (live)

Affected module(s) Parser

Expected behavior, and steps to reproduce if appropriate

$parser = \Config\Services::parser();
$data   = [
    'company' => 'Problem',
    'company_name' => 'X Company',
    'company_street' => 'Street Name',
    'company_city' => 'City Name',
    'company_country' => 'England',
];
$template = '<html> {company_name} <br> {company_street} <br>  {company_city} <br>  {company_country} </html>';
$parser->setData($data);
echo $parser->renderString($template);

Context

paulbalandan commented 3 years ago

This has been fixed in #3749