Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(376)

Unified Diff: Source/core/css/CSSGrammar.y

Issue 320783002: CSSGrammer.y should not allow missing closing bracket when it parses querySelector's selector text. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/css/parsing-unexpected-eof.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/CSSGrammar.y
diff --git a/Source/core/css/CSSGrammar.y b/Source/core/css/CSSGrammar.y
index 97d1672e06a11feead3e4e79a15d887a78189d15..0555e419982dc33610130b576aeb49067ee5e779 100644
--- a/Source/core/css/CSSGrammar.y
+++ b/Source/core/css/CSSGrammar.y
@@ -288,6 +288,8 @@ inline static CSSParserValue makeIdentValue(CSSParserString string)
%type <rule> viewport
%type <boolean> keyframes_rule_start
+%type <boolean> closing_square_bracket
+%type <boolean> closing_parenthesis
%type <string> maybe_ns_prefix
%type <string> namespace_selector
@@ -455,13 +457,21 @@ closing_brace:
;
closing_parenthesis:
- ')'
- | %prec LOWEST_PREC TOKEN_EOF
+ ')' { $$ = true; }
+ | %prec LOWEST_PREC TOKEN_EOF {
+ // While parsing query selector's selector text, we should not
+ // allow missing closing parenthesis.
+ $$ = !parser->m_selectorListForParseSelector;
+ }
;
closing_square_bracket:
- ']'
- | %prec LOWEST_PREC TOKEN_EOF
+ ']' { $$ = true; }
+ | %prec LOWEST_PREC TOKEN_EOF {
+ // While parsing query selector's selector text, we should not
+ // allow missing closing square bracket.
+ $$ = !parser->m_selectorListForParseSelector;
+ }
;
semi_or_eof:
@@ -1242,22 +1252,30 @@ attr_name:
attrib:
'[' maybe_space attr_name closing_square_bracket {
+ if (!$4)
+ YYERROR;
$$ = parser->createFloatingSelector();
$$->setAttribute(QualifiedName(nullAtom, $3, nullAtom));
$$->setMatch(CSSSelector::Set);
}
| '[' maybe_space attr_name match maybe_space ident_or_string maybe_space closing_square_bracket {
+ if (!$8)
+ YYERROR;
$$ = parser->createFloatingSelector();
$$->setAttribute(QualifiedName(nullAtom, $3, nullAtom));
$$->setMatch((CSSSelector::Match)$4);
$$->setValue($6);
}
| '[' maybe_space namespace_selector attr_name closing_square_bracket {
+ if (!$5)
+ YYERROR;
$$ = parser->createFloatingSelector();
$$->setAttribute(parser->determineNameInNamespace($3, $4));
$$->setMatch(CSSSelector::Set);
}
| '[' maybe_space namespace_selector attr_name match maybe_space ident_or_string maybe_space closing_square_bracket {
+ if (!$9)
+ YYERROR;
$$ = parser->createFloatingSelector();
$$->setAttribute(parser->determineNameInNamespace($3, $4));
$$->setMatch((CSSSelector::Match)$5);
@@ -1337,6 +1355,8 @@ pseudo:
}
// used by ::cue(:past/:future)
| ':' ':' CUEFUNCTION maybe_space simple_selector_list maybe_space closing_parenthesis {
+ if (!$7)
+ YYERROR;
$$ = parser->createFloatingSelector();
$$->setMatch(CSSSelector::PseudoElement);
$$->adoptSelectorVector(*parser->sinkFloatingSelectorVector($5));
@@ -1354,6 +1374,8 @@ pseudo:
// See http://lists.w3.org/Archives/Public/www-style/2010Sep/0566.html for some
// related discussion with respect to :not.
| ':' ANYFUNCTION maybe_space simple_selector_list maybe_space closing_parenthesis {
+ if (!$6)
+ YYERROR;
$$ = parser->createFloatingSelector();
$$->setMatch(CSSSelector::PseudoClass);
$$->adoptSelectorVector(*parser->sinkFloatingSelectorVector($4));
@@ -1368,6 +1390,8 @@ pseudo:
}
// used by :nth-*(ax+b)
| ':' FUNCTION maybe_space NTH maybe_space closing_parenthesis {
+ if (!$6)
+ YYERROR;
$$ = parser->createFloatingSelector();
$$->setMatch(CSSSelector::PseudoClass);
$$->setArgument($4);
@@ -1378,6 +1402,8 @@ pseudo:
}
// used by :nth-*
| ':' FUNCTION maybe_space maybe_unary_operator INTEGER maybe_space closing_parenthesis {
+ if (!$7)
+ YYERROR;
$$ = parser->createFloatingSelector();
$$->setMatch(CSSSelector::PseudoClass);
$$->setArgument(AtomicString::number($4 * $5));
@@ -1388,6 +1414,8 @@ pseudo:
}
// used by :nth-*(odd/even) and :lang
| ':' FUNCTION maybe_space IDENT maybe_space closing_parenthesis {
+ if (!$6)
+ YYERROR;
$$ = parser->createFloatingSelector();
$$->setMatch(CSSSelector::PseudoClass);
$$->setArgument($4);
@@ -1409,6 +1437,8 @@ pseudo:
}
// used by :not
| ':' NOTFUNCTION maybe_space simple_selector maybe_space closing_parenthesis {
+ if (!$6)
+ YYERROR;
if (!$4->isSimple())
YYERROR;
else {
@@ -1427,6 +1457,8 @@ pseudo:
YYERROR;
}
| ':' HOSTFUNCTION maybe_space simple_selector_list maybe_space closing_parenthesis {
+ if (!$6)
+ YYERROR;
$$ = parser->createFloatingSelector();
$$->setMatch(CSSSelector::PseudoClass);
$$->adoptSelectorVector(*parser->sinkFloatingSelectorVector($4));
@@ -1441,6 +1473,8 @@ pseudo:
}
// used by :host-context()
| ':' HOSTCONTEXTFUNCTION maybe_space simple_selector_list maybe_space closing_parenthesis {
+ if (!$6)
+ YYERROR;
$$ = parser->createFloatingSelector();
$$->setMatch(CSSSelector::PseudoClass);
$$->adoptSelectorVector(*parser->sinkFloatingSelectorVector($4));
« no previous file with comments | « LayoutTests/fast/css/parsing-unexpected-eof.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698