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

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

Issue 836373002: Make media query feature values more strict (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add two more tests 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 158280edabf8584f849ad076296a0991ddf4fc99..4e599ee892e28c995891bd2c2fa08dad938c0c93 100644
--- a/Source/core/css/parser/MediaQueryParser.cpp
+++ b/Source/core/css/parser/MediaQueryParser.cpp
@@ -140,8 +140,10 @@ void MediaQueryParser::readFeatureValue(CSSParserTokenType type, const CSSParser
if (type == DimensionToken && token.unitType() == CSSPrimitiveValue::CSS_UNKNOWN) {
m_state = SkipUntilComma;
} else {
- m_mediaQueryData.addParserValue(type, token);
- m_state = ReadFeatureEnd;
+ if (m_mediaQueryData.tryAddParserValue(type, token))
+ m_state = ReadFeatureEnd;
+ else
+ m_state = SkipUntilBlockEnd;
}
}
@@ -153,7 +155,7 @@ void MediaQueryParser::readFeatureEnd(CSSParserTokenType type, const CSSParserTo
else
m_state = SkipUntilComma;
} else if (type == DelimiterToken && token.delimiter() == '/') {
- m_mediaQueryData.addParserValue(type, token);
+ m_mediaQueryData.tryAddParserValue(type, token);
m_state = ReadFeatureValue;
} else {
m_state = SkipUntilBlockEnd;
@@ -248,7 +250,7 @@ bool MediaQueryData::addExpression()
return isValid;
}
-void MediaQueryData::addParserValue(CSSParserTokenType type, const CSSParserToken& token)
+bool MediaQueryData::tryAddParserValue(CSSParserTokenType type, const CSSParserToken& token)
{
CSSParserValue value;
if (type == NumberToken || type == PercentageToken || type == DimensionToken) {
@@ -259,15 +261,18 @@ void MediaQueryData::addParserValue(CSSParserTokenType type, const CSSParserToke
value.iValue = token.delimiter();
value.id = CSSValueInvalid;
value.isInt = false;
- } else {
+ } else if (type == IdentToken) {
CSSParserString tokenValue;
tokenValue.init(token.value());
value.unit = CSSPrimitiveValue::CSS_IDENT;
value.string = tokenValue;
value.id = cssValueKeywordID(tokenValue);
value.isInt = false;
+ } else {
+ return false;
}
m_valueList.addValue(value);
+ return true;
}
void MediaQueryData::setMediaType(const String& mediaType)
« 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