feat: handle backslash in @utility name#19626
Open
rozsazoltan wants to merge 3 commits intotailwindlabs:mainfrom
Open
feat: handle backslash in @utility name#19626rozsazoltan wants to merge 3 commits intotailwindlabs:mainfrom
@utility name#19626rozsazoltan wants to merge 3 commits intotailwindlabs:mainfrom
Conversation
Contributor
WalkthroughAdds an unescape step when handling 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Contributor
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/tailwindcss/src/index.ts`:
- Around line 234-235: The current blanket removal of backslashes (node.params =
node.params.replace(/\\/g, '')) breaks CSS hex/char escapes; replace that line
to call the existing unescape helper (e.g., node.params = unescape(node.params))
so CSS escapes like \61 are decoded correctly while still producing literal
characters for sequences such as \/ and \%; add the unescape import if missing
and ensure you reference the unescape helper when normalizing node.params.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #19607
Summary
I believe there is no obstacle to simply ignoring backslashes in the name. This way, various validators - which are not aware of Tailwind CSS's specific syntax (which allows the
/character to be used directly in utility names) - can still be bypassed using backslashes. For example, instead of@utility push-1/2, one could use@utility push-1\/2, while the end result would be identical.Test plan
I took a previous utility test as a baseline and extended it with backslashes, and I expect the same result in the output as in the original test case: