From 16e86bc0c0e416071fbabbd5f22be0cb115e4364 Mon Sep 17 00:00:00 2001 From: Jakub Kulhan Date: Thu, 8 Mar 2018 00:00:26 +0100 Subject: [PATCH] [CssSelector] Fix CSS identifiers parsing - they can start with dash --- .../CssSelector/Parser/Tokenizer/TokenizerPatterns.php | 2 +- src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerPatterns.php b/src/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerPatterns.php index b548905fa29c..15dfb0eb0e78 100644 --- a/src/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerPatterns.php +++ b/src/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerPatterns.php @@ -44,7 +44,7 @@ public function __construct() $this->nonAsciiPattern = '[^\x00-\x7F]'; $this->nmCharPattern = '[_a-z0-9-]|'.$this->escapePattern.'|'.$this->nonAsciiPattern; $this->nmStartPattern = '[_a-z]|'.$this->escapePattern.'|'.$this->nonAsciiPattern; - $this->identifierPattern = '(?:'.$this->nmStartPattern.')(?:'.$this->nmCharPattern.')*'; + $this->identifierPattern = '-?(?:'.$this->nmStartPattern.')(?:'.$this->nmCharPattern.')*'; $this->hashPattern = '#((?:'.$this->nmCharPattern.')+)'; $this->numberPattern = '[+-]?(?:[0-9]*\.[0-9]+|[0-9]+)'; $this->quotedStringPattern = '([^\n\r\f%s]|'.$this->stringEscapePattern.')*'; diff --git a/src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php b/src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php index 37a3ef1d58de..53b35a95473c 100644 --- a/src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php +++ b/src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php @@ -186,6 +186,7 @@ public function getPseudoElementsTestData() array('foo:after', 'Element[foo]', 'after'), array('foo::selection', 'Element[foo]', 'selection'), array('lorem#ipsum ~ a#b.c[href]:empty::selection', 'CombinedSelector[Hash[Element[lorem]#ipsum] ~ Pseudo[Attribute[Class[Hash[Element[a]#b].c][href]]:empty]]', 'selection'), + array('video::-webkit-media-controls', 'Element[video]', '-webkit-media-controls'), ); }