@@ -60,8 +60,9 @@ public static function parse(ParserState $oParserState, $oList = null)
6060 $ selectors = [];
6161 $ selectorParts = [];
6262 $ stringWrapperCharacter = null ;
63+ $ functionNestingLevel = 0 ;
6364 $ consumedNextCharacter = false ;
64- static $ stopCharacters = ['{ ' , '} ' , '\'' , '" ' , ', ' ];
65+ static $ stopCharacters = ['{ ' , '} ' , '\'' , '" ' , '( ' , ' ) ' , ' , ' ];
6566 do {
6667 if (!$ consumedNextCharacter ) {
6768 $ selectorParts [] = $ oParserState ->consume (1 );
@@ -81,8 +82,21 @@ public static function parse(ParserState $oParserState, $oList = null)
8182 }
8283 }
8384 break ;
84- case ', ' :
85+ case '( ' :
8586 if (!\is_string ($ stringWrapperCharacter )) {
87+ ++$ functionNestingLevel ;
88+ }
89+ break ;
90+ case ') ' :
91+ if (!\is_string ($ stringWrapperCharacter )) {
92+ if ($ functionNestingLevel <= 0 ) {
93+ throw new UnexpectedTokenException ('anything but ' , ') ' );
94+ }
95+ --$ functionNestingLevel ;
96+ }
97+ break ;
98+ case ', ' :
99+ if (!\is_string ($ stringWrapperCharacter ) && $ functionNestingLevel === 0 ) {
86100 $ selectors [] = \implode ('' , $ selectorParts );
87101 $ selectorParts = [];
88102 $ oParserState ->consume (1 );
@@ -91,6 +105,9 @@ public static function parse(ParserState $oParserState, $oList = null)
91105 break ;
92106 }
93107 } while (!\in_array ($ nextCharacter , ['{ ' , '} ' ], true ) || \is_string ($ stringWrapperCharacter ));
108+ if ($ functionNestingLevel !== 0 ) {
109+ throw new UnexpectedTokenException (') ' , $ nextCharacter );
110+ }
94111 $ selectors [] = \implode ('' , $ selectorParts ); // add final or only selector
95112 $ oResult ->setSelectors ($ selectors , $ oList );
96113 if ($ oParserState ->comes ('{ ' )) {
0 commit comments