diff --git a/src/Property/Selector.php b/src/Property/Selector.php index cf07a8f5..130a18ac 100644 --- a/src/Property/Selector.php +++ b/src/Property/Selector.php @@ -46,7 +46,7 @@ class Selector /ix'; /** - * regexp for specificity calculations + * regexp for validity verifications * * @var string * @@ -79,7 +79,9 @@ class Selector */ public static function isValid($sSelector) { - return \preg_match(static::SELECTOR_VALIDATION_RX, $sSelector); + return \preg_match(static::SELECTOR_VALIDATION_RX, $sSelector) + // trim quoted texts and validate colons on the remainder + && !\preg_match('/(? li:last-of-type {border-left-width: 0;}} body {background-color: red;}'; self::assertSame($sExpected, $oDoc->render()); + + $oDoc = self::parsedStructureForFile('invalid-selectors-4', Settings::create()->withMultibyteSupport(true)); + $sExpected = 'body, div :hover {color: green;} +div {color: blue;} +a[href*=": \" "] {color: blue;} +a[href*=\': \" \'] {color: blue;} +#some_id_that_ends_in_a\: > a {color: blue;}'; + self::assertSame($sExpected, $oDoc->render()); } /** diff --git a/tests/fixtures/invalid-selectors-4.css b/tests/fixtures/invalid-selectors-4.css new file mode 100644 index 00000000..787a301f --- /dev/null +++ b/tests/fixtures/invalid-selectors-4.css @@ -0,0 +1,27 @@ +body, div: hover { + color: green; +} + +body, div : hover { + color: green; +} + +body, div :hover { + color: green; +} + +div { + color: blue; +} + +a[href*=": \" "] { + color: blue; +} + +a[href*=': \" '] { + color: blue; +} + +#some_id_that_ends_in_a\: > a { + color: blue; +}