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

Fix/interpolate with multiple nesting keys #1801

Merged
merged 2 commits into from
Aug 2, 2024

Conversation

ferransimon
Copy link
Collaborator

Description

The interpolate function is using a statefull regex but it is being reused without reseting its inner state, in order to handle its statefull nature we need to reset the inner state lastIndex every time we need to reuse it to match something from the beginning.

Example

I found the bug by providing this literal: %[item1]Para verificar tu perfil, por favor revisa el email que te hemos enviado a: %[email][email]%.[item1]%%[item2]¿Este no es tu email? %[changeEmail]Cámbialo ahora[changeEmail]%.[item2]%%[item3]¿No lo has recibido? Revisa tu carpeta de spam o añade pushinfojobs@push.infojobs.net a remitentes seguros.[item3]%%[item4]¿Aún no lo has recibido? %[resend]Te lo reenviamos[resend]%[item4]%

It was handling correctly the first and third nested elements but the second was not able to handle it due to the use of global regex

@ferransimon ferransimon merged commit 5b41211 into master Aug 2, 2024
3 checks passed
@ferransimon ferransimon deleted the fix/interpolateWithMultipleNestingKeys branch August 2, 2024 09:58
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.

5 participants