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

Unified Diff: Source/core/html/parser/HTMLSrcsetParser.cpp

Issue 1306743003: Fix float parsing in srcset (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: clamp to float Created 5 years, 4 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: Source/core/html/parser/HTMLSrcsetParser.cpp
diff --git a/Source/core/html/parser/HTMLSrcsetParser.cpp b/Source/core/html/parser/HTMLSrcsetParser.cpp
index 8283ecd41536a733ce2d23e426c427da4eeffa4c..e14c4e4953ceb6fb67df34d2a843a0d5d279c798 100644
--- a/Source/core/html/parser/HTMLSrcsetParser.cpp
+++ b/Source/core/html/parser/HTMLSrcsetParser.cpp
@@ -97,7 +97,11 @@ struct DescriptorToken {
isValid = false;
return 0;
}
- return charactersToFloat(attribute + start, lengthExcludingDescriptor, &isValid);
+ Decimal result = parseToDecimalForNumberType(String(attribute + start, lengthExcludingDescriptor));
+ isValid = result.isFinite();
+ if (!isValid)
+ return 0;
+ return clampTo<float>(result.toDouble());
tkent 2015/08/25 10:02:46 This looks to have a behavior change for numbers g
Yoav Weiss 2015/08/25 10:07:58 I didn't mean for that to be a behavior change. Is
tkent 2015/08/25 10:14:23 AFAIK, static_cast<float>(greater-than-float-max)
}
};

Powered by Google App Engine
This is Rietveld 408576698