From 00ccbdc93792db77e5eefe508f4e502b8b80f686 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Fri, 20 Dec 2024 09:22:49 -0500 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20detect=20arbitrary=20properties?= =?UTF-8?q?=20when=20preceded=20by=20an=20escape=20(#15456)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a targeted bug fix uncovered by the v4 docs. Given this code: ```html ``` We'd pick up `[a\\]\\:block]` as a candidate which would then make it far enough to get output to CSS and throw an error. This makes sure we don't try to start an arbitrary property if the preceding character is a `\` cc @RobinMalfait this look okay? --------- Co-authored-by: Robin Malfait --- CHANGELOG.md | 1 + crates/oxide/src/parser.rs | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ecc63017d21..0435312a37a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Use the correct property value for `place-content-between`, `place-content-around`, and `place-content-evenly` utilities ([#15440](https://github.com/tailwindlabs/tailwindcss/pull/15440)) +- Don’t detect arbitrary properties when preceded by an escape ([#15456](https://github.com/tailwindlabs/tailwindcss/pull/15456)) ### Changed diff --git a/crates/oxide/src/parser.rs b/crates/oxide/src/parser.rs index 281774261ad6..1c8fdf75c0f2 100644 --- a/crates/oxide/src/parser.rs +++ b/crates/oxide/src/parser.rs @@ -595,7 +595,7 @@ impl<'a> Extractor<'a> { fn parse_start(&mut self) -> ParseAction<'a> { match self.cursor.curr { // Enter arbitrary property mode - b'[' => { + b'[' if self.cursor.prev != b'\\' => { trace!("Arbitrary::Start\t"); self.arbitrary = Arbitrary::Brackets { start_idx: self.cursor.pos, @@ -1634,4 +1634,18 @@ mod test { ] ); } + + #[test] + fn arbitrary_properties_are_not_picked_up_after_an_escape() { + _please_trace(); + let candidates = run( + r#" + + \\[a\\]\\:block] + "#, + false, + ); + + assert_eq!(candidates, vec!["!code", "a"]); + } }