Skip to content

[9.x] Fixes blade escaped tags issue - #45928

Merged
taylorotwell merged 2 commits into
laravel:9.xfrom
imanghafoori1:fix_45915
Feb 2, 2023
Merged

[9.x] Fixes blade escaped tags issue#45928
taylorotwell merged 2 commits into
laravel:9.xfrom
imanghafoori1:fix_45915

Conversation

@imanghafoori1

@imanghafoori1 imanghafoori1 commented Feb 2, 2023

Copy link
Copy Markdown
Contributor

This fixes #45915

In the added test there are 4 matches, in the second replacement @@endforeach with @endforeach in the second replacement.

Then the final replacement searches for @endforeach to replace it with the compiled version, but it finds what was produced by the previously escaped tag because it starts the search from the beginning of the string.

Solution:

Logically when replacing the matches found by REGEX one after the other using Str::replaceFirst, we have to continue from where we last left off.

@imanghafoori1
imanghafoori1 force-pushed the fix_45915 branch 2 times, most recently from 41e2573 to 68181c6 Compare February 2, 2023 20:26
@taylorotwell

Copy link
Copy Markdown
Member

Are all these substr_replace, strlen calls going to work if there are multi-byte characters in the template?

@taylorotwell
taylorotwell merged commit ac18940 into laravel:9.x Feb 2, 2023
@imanghafoori1

Copy link
Copy Markdown
Contributor Author

@taylorotwell I will design some tests for those cases.

@imanghafoori1
imanghafoori1 deleted the fix_45915 branch February 2, 2023 21:32
@imanghafoori1

Copy link
Copy Markdown
Contributor Author

@taylorotwell It works ok with emojis or other 3-bit chars but it needs some testing, because if someone changes strpos to mb_str_pos it will break;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Escaping Blade directives with @@ is broken

2 participants