@@ -106,8 +106,7 @@ private function parseAtRule() {
106
106
} else if (self ::identifierIs ($ sIdentifier , 'keyframes ' )) {
107
107
$ oResult = new KeyFrame ();
108
108
$ oResult ->setVendorKeyFrame ($ sIdentifier );
109
- $ oResult ->setAnimationName (trim ($ this ->consumeUntil ('{ ' )));
110
- $ this ->consume ('{ ' );
109
+ $ oResult ->setAnimationName (trim ($ this ->consumeUntil ('{ ' , false , true )));
111
110
$ this ->consumeWhiteSpace ();
112
111
$ this ->parseList ($ oResult );
113
112
return $ oResult ;
@@ -128,8 +127,7 @@ private function parseAtRule() {
128
127
return new CSSNamespace ($ mUrl , $ sPrefix );
129
128
} else {
130
129
//Unknown other at rule (font-face or such)
131
- $ sArgs = $ this ->consumeUntil ('{ ' );
132
- $ this ->consume ('{ ' );
130
+ $ sArgs = $ this ->consumeUntil ('{ ' , false , true );
133
131
$ this ->consumeWhiteSpace ();
134
132
$ bUseRuleSet = true ;
135
133
foreach (explode ('/ ' , AtRule::BLOCK_RULES ) as $ sBlockRuleName ) {
@@ -246,8 +244,7 @@ private function parseCharacter($bIsForIdentifier) {
246
244
247
245
private function parseSelector () {
248
246
$ oResult = new DeclarationBlock ();
249
- $ oResult ->setSelector ($ this ->consumeUntil ('{ ' ));
250
- $ this ->consume ('{ ' );
247
+ $ oResult ->setSelector ($ this ->consumeUntil ('{ ' , false , true ));
251
248
$ this ->consumeWhiteSpace ();
252
249
$ this ->parseRuleSet ($ oResult );
253
250
return $ oResult ;
@@ -518,9 +515,13 @@ private function consumeWhiteSpace() {
518
515
519
516
private function consumeComment () {
520
517
if ($ this ->comes ('/* ' )) {
521
- $ this ->consumeUntil ('*/ ' );
522
- $ this ->consume ('*/ ' );
523
- return true ;
518
+ $ this ->consume (2 );
519
+ while ($ this ->consumeUntil ('* ' , false , true )) {
520
+ if ($ this ->comes ('/ ' )) {
521
+ $ this ->consume (1 );
522
+ return true ;
523
+ }
524
+ }
524
525
}
525
526
return false ;
526
527
}
@@ -529,22 +530,25 @@ private function isEnd() {
529
530
return $ this ->iCurrentPosition >= $ this ->iLength ;
530
531
}
531
532
532
- private function consumeUntil ($ aEnd , $ bIncludeEnd = false ) {
533
+ private function consumeUntil ($ aEnd , $ bIncludeEnd = false , $ consumeEnd = false ) {
533
534
$ aEnd = is_array ($ aEnd ) ? $ aEnd : array ($ aEnd );
534
- $ iEndPos = null ;
535
- foreach ($ aEnd as $ sEnd ) {
536
- $ iCurrentEndPos = $ this ->strpos ($ this ->sText , $ sEnd , $ this ->iCurrentPosition );
537
- if ($ iCurrentEndPos === false ) {
538
- continue ;
539
- }
540
- if ($ iEndPos === null || $ iCurrentEndPos < $ iEndPos ) {
541
- $ iEndPos = $ iCurrentEndPos + ($ bIncludeEnd ? $ this ->strlen ($ sEnd ) : 0 );
542
- }
543
- }
544
- if ($ iEndPos === null ) {
545
- throw new UnexpectedTokenException ('One of (" ' .implode ('"," ' , $ aEnd ).'") ' , $ this ->peek (5 ), 'search ' );
546
- }
547
- return $ this ->consume ($ iEndPos - $ this ->iCurrentPosition );
535
+ $ out = '' ;
536
+ $ start = $ this ->iCurrentPosition ;
537
+
538
+ while (($ char = $ this ->consume (1 )) !== '' ) {
539
+ if (in_array ($ char , $ aEnd )) {
540
+ if ($ bIncludeEnd ) {
541
+ $ out .= $ char ;
542
+ } elseif (!$ consumeEnd ) {
543
+ $ this ->iCurrentPosition -= $ this ->strlen ($ char );
544
+ }
545
+ return $ out ;
546
+ }
547
+ $ out .= $ char ;
548
+ }
549
+
550
+ $ this ->iCurrentPosition = $ start ;
551
+ throw new UnexpectedTokenException ('One of (" ' .implode ('"," ' , $ aEnd ).'") ' , $ this ->peek (5 ), 'search ' );
548
552
}
549
553
550
554
private function inputLeft () {
0 commit comments