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

Unified Diff: third_party/WebKit/Source/core/css/parser/CSSVariableParser.cpp

Issue 1752773003: Check @apply syntax in custom properties declarations at parse time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
Index: third_party/WebKit/Source/core/css/parser/CSSVariableParser.cpp
diff --git a/third_party/WebKit/Source/core/css/parser/CSSVariableParser.cpp b/third_party/WebKit/Source/core/css/parser/CSSVariableParser.cpp
index a54302eac4ea4fbd6bd498d6e4ff525bb4b30a55..f75d27d8db56646ba167d145887ad5f190ca4ba1 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSVariableParser.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSVariableParser.cpp
@@ -48,10 +48,14 @@ bool classifyBlock(CSSParserTokenRange range, bool& hasReferences, bool isTopLev
const CSSParserToken& token = range.consume();
switch (token.type()) {
case AtKeywordToken: {
- // This might have false positives if the @apply doesn't actually match
- // the syntax, but that just means we do extra computation work.
- if (token.valueEqualsIgnoringASCIICase("apply"))
+ if (token.valueEqualsIgnoringASCIICase("apply")) {
+ range.consumeWhitespace();
+ const CSSParserToken& variableName = range.consumeIncludingWhitespace();
+ if (!CSSVariableParser::isValidVariableName(variableName)
+ || !(range.atEnd() || range.peek().type() == SemicolonToken || range.peek().type() == RightBraceToken))
+ return false;
hasReferences = true;
+ }
break;
}
case DelimiterToken: {

Powered by Google App Engine
This is Rietveld 408576698