-
Notifications
You must be signed in to change notification settings - Fork 144
Look for unmached brace count when parsing generic at-rules #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,6 +142,13 @@ private static function parseAtRule(ParserState $oParserState) { | |
} else { | ||
//Unknown other at rule (font-face or such) | ||
$sArgs = trim($oParserState->consumeUntil('{', false, true)); | ||
if (substr_count($sArgs, "(") != substr_count($sArgs, ")")) { | ||
if($oParserState->getSettings()->bLenientParsing) { | ||
return NULL; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this mean there’s a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are no $oListItem = null;
if($bLenientParsing) {
try {
$oListItem = self::parseListItem($oParserState, $oList);
} catch (UnexpectedTokenException $e) {
$oListItem = false;
}
} else {
$oListItem = self::parseListItem($oParserState, $oList);
}
if($oListItem === null) {
// List parsing finished
return;
} Returning There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I get it now, thanks… There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I presume you meant “resulting CSS will (most likely) be _in_valid” There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant "valid", in the sense that the broken rules will be discarded, but the rest of the rules, which I presume are valid, will be included in the file. However, this will be an issue, since those rules have been previously ignored by the browsers, so including them will most likely alter the final rendering of the page. |
||
} else { | ||
throw new SourceException("Unmatched brace count in media query", $oParserState->currentLine()); | ||
} | ||
} | ||
$bUseRuleSet = true; | ||
foreach(explode('/', AtRule::BLOCK_RULES) as $sBlockRuleName) { | ||
if(self::identifierIs($sIdentifier, $sBlockRuleName)) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
button,input,checkbox,textarea { | ||
outline: 0; | ||
margin: 0; | ||
} | ||
|
||
@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio:3/@media all and (orientation:portrait) { | ||
#wrapper { | ||
max-width:640px; | ||
margin: 0 auto; | ||
} | ||
} | ||
|
||
@media all and (orientation: landscape) { | ||
#wrapper { | ||
max-width:640px; | ||
margin: 0 auto; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this
if
? Can’t we just throw anUnsupportedTokenException
instead of aSourceException
and the calling code will catch it in lenient mode? If that’s not the case, maybe it should be…There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Throwing an
UnsupportedTokenException
will not abort parsing, which leads to other kind of issues.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disregard this, then…