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

Unified Diff: Source/core/css/parser/MediaQueryParser.cpp

Issue 867363002: Some invalid media queries are parsed as valid (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address review comments Created 5 years, 11 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 | « Source/core/css/parser/MediaQueryParser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/parser/MediaQueryParser.cpp
diff --git a/Source/core/css/parser/MediaQueryParser.cpp b/Source/core/css/parser/MediaQueryParser.cpp
index f1a1a2438223bb92fdd8678db216f0cff21c14f5..34f5c9b26ca99b83d421205862f0d9aeaa740486 100644
--- a/Source/core/css/parser/MediaQueryParser.cpp
+++ b/Source/core/css/parser/MediaQueryParser.cpp
@@ -76,15 +76,30 @@ void MediaQueryParser::readMediaNot(CSSParserTokenType type, const CSSParserToke
readFeatureStart(type, token);
}
+static bool isRestrictorOrLogicalOperator(const String& tokenValue)
+{
+ // FIXME: it would be more efficient to use lower-case always for tokenValue.
+ return equalIgnoringCase(tokenValue, "not")
+ || equalIgnoringCase(tokenValue, "and")
+ || equalIgnoringCase(tokenValue, "or")
+ || equalIgnoringCase(tokenValue, "only");
+}
+
void MediaQueryParser::readMediaType(CSSParserTokenType type, const CSSParserToken& token)
{
if (type == LeftParenthesisToken) {
- m_state = ReadFeature;
+ if (m_mediaQueryData.restrictor() != MediaQuery::None)
+ m_state = SkipUntilComma;
+ else
+ m_state = ReadFeature;
} else if (type == IdentToken) {
if (m_state == ReadRestrictor && equalIgnoringCase(token.value(), "not")) {
setStateAndRestrict(ReadMediaType, MediaQuery::Not);
} else if (m_state == ReadRestrictor && equalIgnoringCase(token.value(), "only")) {
setStateAndRestrict(ReadMediaType, MediaQuery::Only);
+ } else if (m_mediaQueryData.restrictor() != MediaQuery::None
+ && isRestrictorOrLogicalOperator(token.value())) {
+ m_state = SkipUntilComma;
} else {
m_mediaQueryData.setMediaType(token.value());
m_state = ReadAnd;
« no previous file with comments | « Source/core/css/parser/MediaQueryParser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698