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] playground, compiler: correctly escape template literals #1611

Merged
merged 2 commits into from
May 13, 2024

Conversation

sdegueldre
Copy link
Contributor

This PR contains two commits that fix incomplete or inexistant escaping of strings that were injected into constructed template literals. See the individual commits for details.

Previously, there were a few places where the compiler would create
strings from template content and emit them as template literals, but
didn't properly escape characters or character sequences with special
meanings, in particular: backslashes, backticks, and interpolation
sigils.

This commit fixes this in:
- block creation (interpolation sigils were not escaped)
- text node creation (no escaping was performed)
- comment not creation (no escaping was performed)
- default values for t-esc (no escaping was performed)
- body of a t-set (no escaping was performed)
Previously, if you used a backslash in a template on the playground, it
would be interpreted as an escape sequence, and if you wrote "${" it
would likely crash, as it would be treated as an interpolation sigil in
the context of the script element injected inside the playground's
iframe.

A previous fix already escaped backticks, this commit completes the
escaping by escaping the two other things that have special meaning
within template literals.
@sdegueldre sdegueldre force-pushed the master-template-literal-fix-sad branch from ace13a2 to 110e7a8 Compare May 13, 2024 13:33
@ged-odoo ged-odoo merged commit 7952f31 into master May 13, 2024
3 checks passed
@ged-odoo ged-odoo deleted the master-template-literal-fix-sad branch May 13, 2024 13:35
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.

None yet

2 participants