Skip to content

Commit 4535fca

Browse files
committed
Merge branch 'fix/arithmetic-in-functions' into testing-2022
2 parents 0ea8318 + ec9fc7c commit 4535fca

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

src/Value/Value.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ public static function parseValue(ParserState $oParserState, array $aListDelimit
7272
}
7373
$iStartPosition = null;
7474
while (($iStartPosition = array_search($sDelimiter, $aStack, true)) !== false) {
75+
if ($iStartPosition === 0) {
76+
break;
77+
}
7578
$iLength = 2; //Number of elements to be joined
7679
for ($i = $iStartPosition + 2; $i < count($aStack); $i += 2, ++$iLength) {
7780
if ($sDelimiter !== $aStack[$i]) {

tests/ParserTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,6 +1301,16 @@ public function functionArithmeticInFile()
13011301
self::assertSame($sExpected, $oDoc->render());
13021302
}
13031303

1304+
/**
1305+
* @test
1306+
*/
1307+
public function infiniteLoopInFile()
1308+
{
1309+
$oDoc = self::parsedStructureForFile('infinite-loop', Settings::create()->withMultibyteSupport(true));
1310+
$sExpected = 'div {}';
1311+
self::assertSame($sExpected, $oDoc->render());
1312+
}
1313+
13041314
public function escapedSpecialCaseTokens()
13051315
{
13061316
$oDoc = $this->parsedStructureForFile('escaped-tokens');

tests/fixtures/infinite-loop.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
div {
2+
height: ///!;
3+
}

0 commit comments

Comments
 (0)