Skip to content

Commit 1f6d61f

Browse files
committed
Validate named values in candidate parser
Candidates that don’t pass this test already won’t get picked up by Oxide so shouldn’t be any worry of compatibility issues
1 parent de80788 commit 1f6d61f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/tailwindcss/src/candidate.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const COLON = 0x3a
1010
const DASH = 0x2d
1111
const LOWER_A = 0x61
1212
const LOWER_Z = 0x7a
13+
const IS_VALID_NAMED_VALUE = /^[a-zA-Z0-9_.%-]+$/
1314

1415
export type ArbitraryUtilityValue = {
1516
kind: 'arbitrary'
@@ -596,6 +597,8 @@ export function* parseCandidate(input: string, designSystem: DesignSystem): Iter
596597
? null
597598
: `${value}/${modifierSegment}`
598599

600+
if (!IS_VALID_NAMED_VALUE.test(value)) continue
601+
599602
candidate.value = {
600603
kind: 'named',
601604
value,
@@ -647,6 +650,8 @@ function parseModifier(modifier: string): CandidateModifier | null {
647650
}
648651
}
649652

653+
if (!IS_VALID_NAMED_VALUE.test(modifier)) return null
654+
650655
return {
651656
kind: 'named',
652657
value: modifier,
@@ -798,6 +803,8 @@ export function parseVariant(variant: string, designSystem: DesignSystem): Varia
798803
}
799804
}
800805

806+
if (!IS_VALID_NAMED_VALUE.test(value)) continue
807+
801808
return {
802809
kind: 'functional',
803810
root,

0 commit comments

Comments
 (0)