Skip to content

Commit 3079ac5

Browse files
authored
Merge pull request MyIntervals#120 from FMCorz/consume-expression
Consume expression to indicate how many characters to look ahead
2 parents 50a802f + e976209 commit 3079ac5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/Sabberworm/CSS/Parser.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ private function parseCharacter($bIsForIdentifier) {
265265
if (preg_match('/[0-9a-fA-F]/Su', $this->peek()) === 0) {
266266
return $this->consume(1);
267267
}
268-
$sUnicode = $this->consumeExpression('/^[0-9a-fA-F]{1,6}/u');
268+
$sUnicode = $this->consumeExpression('/^[0-9a-fA-F]{1,6}/u', 6);
269269
if ($this->strlen($sUnicode) < 6) {
270270
//Consume whitespace after incomplete unicode escape
271271
if (preg_match('/\\s/isSu', $this->peek())) {
@@ -565,9 +565,10 @@ private function consume($mValue = 1) {
565565
}
566566
}
567567

568-
private function consumeExpression($mExpression) {
568+
private function consumeExpression($mExpression, $iMaxLength = null) {
569569
$aMatches = null;
570-
if (preg_match($mExpression, $this->inputLeft(), $aMatches, PREG_OFFSET_CAPTURE) === 1) {
570+
$sInput = $iMaxLength !== null ? $this->peek($iMaxLength) : $this->inputLeft();
571+
if (preg_match($mExpression, $sInput, $aMatches, PREG_OFFSET_CAPTURE) === 1) {
571572
return $this->consume($aMatches[0][0]);
572573
}
573574
throw new UnexpectedTokenException($mExpression, $this->peek(5), 'expression', $this->iLineNo);

0 commit comments

Comments
 (0)