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

Parser won't properly parse tags that have a similar name #3841

Closed
LucasKovacs opened this issue Nov 1, 2020 · 1 comment
Closed

Parser won't properly parse tags that have a similar name #3841

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

Comments

@LucasKovacs
Copy link

LucasKovacs commented Nov 1, 2020

Describe the bug
The Parser fails to properly parse tags that have a similar name. It seems that the issue is on the regex on Parser::replaceSingle. Maybe it's to greedy and is just trying to replace also tags that are similarly prefixed. In my case I have two similar tags like:

{parser_test}
{parser_test_second}

So when it finds that {parser_test_second} it replaces it ignoring the _second part.

This can be verified with a simple experiment, if I change the order of the tags in the array that I pass to setData, the replacement is properly done, replacing first {parser_test_second} and then {parser_test}

One weird thing to notice, is that is not reproducible 100% of the times, being a few times where, other tags, are properly replaced.

CodeIgniter 4 version
4.0.4

Affected module(s)
Parser

Expected behavior, and steps to reproduce if appropriate
If I pass similar tags to the parser it won't properly parse them.

Situation

$this->parser = \Config\Services::parser();
$this->parser->setData(['parser_test' => 'parser test', 'parser_test_second' => 'parser test second'], 'raw')->render('index.html');

On my index.html I have

{parser_test}
{parser_test_second}

Actual behaviour

Both tags are replaced with

parser test
parser test

Expected behaviour
parser test
parser test second

Context

  • OS: [Linux]
  • Web server [Apache/2.4.38 (Debian)]
  • PHP version [7.4.10]
@LucasKovacs LucasKovacs added the bug Verified issues on the current code behavior or pull requests that will fix them label Nov 1, 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