Skip to content

Commit b44653f

Browse files
committedMar 12, 2025
throw out values when ${ pattern occurs
If this occurs inside of strings then it's fine but everywhere else it's thrown out. Technically you can set it in the value of a CSS variable, but I think guarding against that is only needed if somebody actually runs into problems with this.
1 parent e87082e commit b44653f

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
 

‎crates/oxide/src/extractor/arbitrary_property_machine.rs

+8
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@ impl Machine for ArbitraryPropertyMachine<ParsingValueState> {
226226
// URLs are not allowed
227227
Class::Slash if start_of_value_pos == cursor.pos => return self.restart(),
228228

229+
// String interpolation-like syntax is not allowed. E.g.: `[${x}]`
230+
Class::Dollar if matches!(cursor.next.into(), Class::OpenCurly) => {
231+
return self.restart()
232+
}
233+
229234
// Everything else is valid
230235
_ => cursor.advance(),
231236
};
@@ -276,6 +281,9 @@ enum Class {
276281
#[bytes(b'-')]
277282
Dash,
278283

284+
#[bytes(b'$')]
285+
Dollar,
286+
279287
#[bytes_range(b'a'..=b'z')]
280288
AlphaLower,
281289

‎crates/oxide/src/extractor/arbitrary_value_machine.rs

+8
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ impl Machine for ArbitraryValueMachine {
9595
// Any kind of whitespace is not allowed
9696
Class::Whitespace => return self.restart(),
9797

98+
// String interpolation-like syntax is not allowed. E.g.: `[${x}]`
99+
Class::Dollar if matches!(cursor.next.into(), Class::OpenCurly) => {
100+
return self.restart()
101+
}
102+
98103
// Everything else is valid
99104
_ => cursor.advance(),
100105
};
@@ -133,6 +138,9 @@ enum Class {
133138
#[bytes(b' ', b'\t', b'\n', b'\r', b'\x0C')]
134139
Whitespace,
135140

141+
#[bytes(b'$')]
142+
Dollar,
143+
136144
#[fallback]
137145
Other,
138146
}

0 commit comments

Comments
 (0)