Title: [209383] trunk/Source/WebCore
- Revision
- 209383
- Author
- [email protected]
- Date
- 2016-12-05 20:34:51 -0800 (Mon, 05 Dec 2016)
Log Message
[CSS Parser] Properly reject large numeric values
https://bugs.webkit.org/show_bug.cgi?id=165455
Reviewed by Zalan Bujtas.
The new parser clamped numeric values in both the slow and fast paths to the max
and min float values. The old parser simply allowed the values to be inf, and then
had std::isinf checks to reject.
Blink rejects also even though it clamps, but I could not discern the mechanism by
which they did so. Therefore I am changing the new parser to exactly match the old
parser. Numeric values are no longer clamped, but instead are allowed to be inf, and
isinf checks now exist in the new parser in the same places they do in the old parser.
* css/parser/CSSParserFastPaths.cpp:
(WebCore::parseSimpleLength):
(WebCore::parseSimpleLengthValue):
* css/parser/CSSParserToken.cpp:
(WebCore::CSSParserToken::CSSParserToken):
* css/parser/CSSPropertyParserHelpers.cpp:
(WebCore::CSSPropertyParserHelpers::consumeLength):
(WebCore::CSSPropertyParserHelpers::consumePercent):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (209382 => 209383)
--- trunk/Source/WebCore/ChangeLog 2016-12-06 03:37:29 UTC (rev 209382)
+++ trunk/Source/WebCore/ChangeLog 2016-12-06 04:34:51 UTC (rev 209383)
@@ -1,3 +1,28 @@
+2016-12-05 Dave Hyatt <[email protected]>
+
+ [CSS Parser] Properly reject large numeric values
+ https://bugs.webkit.org/show_bug.cgi?id=165455
+
+ Reviewed by Zalan Bujtas.
+
+ The new parser clamped numeric values in both the slow and fast paths to the max
+ and min float values. The old parser simply allowed the values to be inf, and then
+ had std::isinf checks to reject.
+
+ Blink rejects also even though it clamps, but I could not discern the mechanism by
+ which they did so. Therefore I am changing the new parser to exactly match the old
+ parser. Numeric values are no longer clamped, but instead are allowed to be inf, and
+ isinf checks now exist in the new parser in the same places they do in the old parser.
+
+ * css/parser/CSSParserFastPaths.cpp:
+ (WebCore::parseSimpleLength):
+ (WebCore::parseSimpleLengthValue):
+ * css/parser/CSSParserToken.cpp:
+ (WebCore::CSSParserToken::CSSParserToken):
+ * css/parser/CSSPropertyParserHelpers.cpp:
+ (WebCore::CSSPropertyParserHelpers::consumeLength):
+ (WebCore::CSSPropertyParserHelpers::consumePercent):
+
2016-12-05 Ricky Mondello <[email protected]>
STP 19 fails to launch on 16B255
Modified: trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp (209382 => 209383)
--- trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp 2016-12-06 03:37:29 UTC (rev 209382)
+++ trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp 2016-12-06 04:34:51 UTC (rev 209383)
@@ -118,7 +118,6 @@
number = charactersToDouble(characters, length, &ok);
if (!ok)
return false;
- number = clampTo<double>(number, -std::numeric_limits<float>::max(), std::numeric_limits<float>::max());
return true;
}
@@ -151,6 +150,8 @@
if (number < 0 && !acceptsNegativeNumbers)
return nullptr;
+ if (std::isinf(number))
+ return nullptr;
return CSSPrimitiveValue::create(number, unit);
}
Modified: trunk/Source/WebCore/css/parser/CSSParserToken.cpp (209382 => 209383)
--- trunk/Source/WebCore/css/parser/CSSParserToken.cpp 2016-12-06 03:37:29 UTC (rev 209382)
+++ trunk/Source/WebCore/css/parser/CSSParserToken.cpp 2016-12-06 04:34:51 UTC (rev 209383)
@@ -235,7 +235,7 @@
, m_unit(static_cast<unsigned>(CSSPrimitiveValue::UnitTypes::CSS_NUMBER))
{
ASSERT(type == NumberToken);
- m_numericValue = clampTo<double>(numericValue, -std::numeric_limits<float>::max(), std::numeric_limits<float>::max());
+ m_numericValue = numericValue;
}
CSSParserToken::CSSParserToken(CSSParserTokenType type, UChar32 start, UChar32 end)
Modified: trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp (209382 => 209383)
--- trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp 2016-12-06 03:37:29 UTC (rev 209382)
+++ trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp 2016-12-06 04:34:51 UTC (rev 209383)
@@ -208,7 +208,7 @@
default:
return nullptr;
}
- if (valueRange == ValueRangeNonNegative && token.numericValue() < 0)
+ if ((valueRange == ValueRangeNonNegative && token.numericValue() < 0) || std::isinf(token.numericValue()))
return nullptr;
return CSSValuePool::singleton().createValue(range.consumeIncludingWhitespace().numericValue(), token.unitType());
}
@@ -216,6 +216,8 @@
if (!shouldAcceptUnitlessValue(token.numericValue(), cssParserMode, unitless)
|| (valueRange == ValueRangeNonNegative && token.numericValue() < 0))
return nullptr;
+ if (std::isinf(token.numericValue()))
+ return nullptr;
CSSPrimitiveValue::UnitTypes unitType = CSSPrimitiveValue::UnitTypes::CSS_PX;
return CSSValuePool::singleton().createValue(range.consumeIncludingWhitespace().numericValue(), unitType);
}
@@ -231,7 +233,7 @@
{
const CSSParserToken& token = range.peek();
if (token.type() == PercentageToken) {
- if (valueRange == ValueRangeNonNegative && token.numericValue() < 0)
+ if ((valueRange == ValueRangeNonNegative && token.numericValue() < 0) || std::isinf(token.numericValue()))
return nullptr;
return CSSValuePool::singleton().createValue(range.consumeIncludingWhitespace().numericValue(), CSSPrimitiveValue::UnitTypes::CSS_PERCENTAGE);
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes