Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/RuleSet/RuleSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ public static function parseRuleSet(ParserState $oParserState, RuleSet $oRuleSet
$oRule = Rule::parse($oParserState);
} catch (UnexpectedTokenException $e) {
try {
$sConsume = $oParserState->consumeUntil(["\n", ';', '}'], true);
$sConsume = $oParserState->consumeUntil(["\n", ';', '{', '}'], true);
// We need to “unfind” the matches to the end of the ruleSet as this will be matched later
if ($oParserState->streql(\substr($sConsume, -1), '}')) {
if ($oParserState->streql(\substr($sConsume, -1), '{')) { // We need to skip the entire block
$oParserState->consumeUntil('}', true);
} elseif ($oParserState->streql(\substr($sConsume, -1), '}')) {
$oParserState->backtrack(1);
} else {
while ($oParserState->comes(';')) {
Expand Down
13 changes: 13 additions & 0 deletions tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,19 @@ public function selectorEscapesInFile(): void
self::assertSame($sExpected, $oDoc->render());
}

/**
* @test
*/
public function invalidRulesInFile(): void
{
$oDoc = $this->parsedStructureForFile('invalid-rule', Settings::create()->withMultibyteSupport(true));
$sExpected = 'fusion-max-sh-shbp {}
@media only screen and (max-width: 800px) {.has-sidebar #content {order: 1;}
.has-sidebar #sidebar {order: 2;margin-top: 50px;}
.has-sidebar #sidebar-2 {order: 3;margin-top: 50px;}}';
self::assertSame($sExpected, $oDoc->render());
}

/**
* @test
*/
Expand Down
21 changes: 21 additions & 0 deletions tests/fixtures/invalid-rule.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
fusion-max-sh-shbp {
.fusion-mobile-nav-holder .wpml-ls-item .menu-text,.fusion-mobile-nav-holder .wpml-ls-item > a,.wpml-ls-item .menu-text, .wpml-ls-item .sub-menu a > span {
justify-content: flex-start;
}
}

@media only screen and (max-width: 800px) {
.has-sidebar #content {
order:1;
}

.has-sidebar #sidebar {
order: 2;
margin-top: 50px;
}

.has-sidebar #sidebar-2 {
order: 3;
margin-top: 50px;
}
}