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

Only re-apply string escaping when necessary #295

Merged
merged 2 commits into from
Jun 17, 2024

Conversation

thecrypticace
Copy link
Contributor

@thecrypticace thecrypticace commented Jun 14, 2024

In #286 we fixed a situation in which escapes were being stripped from strings. This is because StringLiteral nodes in an expression have both escaped and unescaped values.

However, it seems that some StringLiteral nodes do not do this even though they are otherwise identical. Any StringLiteral that is the direct value of a JSX attribute does not perform any escaping.

For example, given these two JSX nodes, you will get the following as the AST:

// The first one
;<div class={"before:content-['\\\\2248']"} />

// The second one
;<div class="before:content-['\\\\2248']" />

image

So we have to detect whether or not escaping was applied originally before doing that ourselves.

tl;dr software is hard 😅

Fixes #294

@thecrypticace thecrypticace merged commit a5506a9 into main Jun 17, 2024
1 check passed
@thecrypticace thecrypticace deleted the fix/escape-only-when-necessary branch June 17, 2024 15:33
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.

Formating adds escape backslashes again and again with each run in 0.6.5
2 participants