Support plugin version mid-portions with leading zeros.
Now supported: 1.02.3.4
Remains unsupported: 01.2.3.4
BUG=460642
Review URL: https://codereview.chromium.org/949573002
Cr-Commit-Position: refs/heads/master@{#317524}
diff --git a/base/version.cc b/base/version.cc
index 6318b35..933356e 100644
--- a/base/version.cc
+++ b/base/version.cc
@@ -31,6 +31,8 @@
for (std::vector<std::string>::const_iterator it = numbers.begin();
it != numbers.end(); ++it) {
+ if (StartsWithASCII(*it, "+", false))
+ return false;
int num;
if (!StringToInt(*it, &num))
return false;
@@ -42,8 +44,8 @@
if (num > max)
return false;
- // This throws out things like +3, or 032.
- if (IntToString(num) != *it)
+ // This throws out leading zeros for the first item only.
+ if (it == numbers.begin() && IntToString(num) != *it)
return false;
parsed->push_back(static_cast<uint16>(num));