Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
eSkiSo opened this issue Oct 27, 2020 · 1 comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@eSkiSo
Copy link
Contributor

eSkiSo commented Oct 27, 2020

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);
  • Current Output
Problem
Problem
Problem
Problem 
  • What was expected
X Company
Street Name
City Name
England
  • Also if the first key on the array is company_c instead of company this will be the output:
X Company
Street Name
Problem
Problem

Context

  • OS: 18.04.5 LTS
  • Web server: Apache/2.4.29
  • PHP version: PHP 7.4.10
@eSkiSo eSkiSo added the bug Verified issues on the current code behavior or pull requests that will fix them label Oct 27, 2020
@paulbalandan
Copy link
Member

This has been fixed in #3749

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

No branches or pull requests

2 participants