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

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

Merged
merged 2 commits into from
Feb 2, 2023
Merged

Conversation

imanghafoori1
Copy link
Contributor

@imanghafoori1 imanghafoori1 commented Feb 2, 2023

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
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
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
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