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

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: switched clamp to cast 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..b9910d859fe997daa7175c2d0744fe8affa8bbc6 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 static_cast<float>(result.toDouble());
}
};

Powered by Google App Engine
This is Rietveld 408576698