Skip to content

Commit a27e301

Browse files
committed
Simplify the CSS validating regex
1 parent 2943d9f commit a27e301

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/Sabberworm/CSS/Property/Selector.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ class Selector {
3838
/ix';
3939

4040
const SELECTOR_VALIDATION_RX = '/
41-
^((?:[a-zA-Z0-9\x{00A0}-\x{FFFF}_\^\$\|\*\=\"\'\~\[\]\(\)\-\s\.:#\+\>]*(?:\\\\.)?(?:\'.*?\')?(?:\".*?\")?)*|\s*?[\+-]?\d+\%\s*)$
41+
^(
42+
(?:
43+
[a-zA-Z0-9\x{00A0}-\x{FFFF}_^$|*="\'~\[\]()\-\s\.:#+>]* # any sequence of valid unescaped characters
44+
(?:\\\\.)? # a single escaped character
45+
(?:([\'"]).*?(?<!\\\\)\2)? # a quoted text like [id="example"]
46+
)*
47+
)$
4248
/ux';
4349

4450
private $sSelector;

0 commit comments

Comments
 (0)