Skip to content

Commit 00ccbdc

Browse files
Don’t detect arbitrary properties when preceded by an escape (#15456)
This is a targeted bug fix uncovered by the v4 docs. Given this code: ```html <!-- [!code word:group-has-\\[a\\]\\:block] --> ``` 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 <malfait.robin@gmail.com>
1 parent 34340e3 commit 00ccbdc

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Fixed
1111

1212
- 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))
13+
- Don’t detect arbitrary properties when preceded by an escape ([#15456](https://github.com/tailwindlabs/tailwindcss/pull/15456))
1314

1415
### Changed
1516

crates/oxide/src/parser.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ impl<'a> Extractor<'a> {
595595
fn parse_start(&mut self) -> ParseAction<'a> {
596596
match self.cursor.curr {
597597
// Enter arbitrary property mode
598-
b'[' => {
598+
b'[' if self.cursor.prev != b'\\' => {
599599
trace!("Arbitrary::Start\t");
600600
self.arbitrary = Arbitrary::Brackets {
601601
start_idx: self.cursor.pos,
@@ -1634,4 +1634,18 @@ mod test {
16341634
]
16351635
);
16361636
}
1637+
1638+
#[test]
1639+
fn arbitrary_properties_are_not_picked_up_after_an_escape() {
1640+
_please_trace();
1641+
let candidates = run(
1642+
r#"
1643+
<!-- [!code word:group-has-\\[a\\]\\:block] -->
1644+
\\[a\\]\\:block]
1645+
"#,
1646+
false,
1647+
);
1648+
1649+
assert_eq!(candidates, vec!["!code", "a"]);
1650+
}
16371651
}

0 commit comments

Comments
 (0)