}
std::string StepParse::GetPackageVersion(
- const std::string& manifest_version) {
- if (manifest_version.empty()) {
+ const std::string& manifest_version) {
+ if (manifest_version.empty())
return kManifestVersion;
- }
- std::string version = manifest_version.substr(0,
- manifest_version.find_first_not_of("1234567890."));
- return version;
+ for (const char& c : manifest_version) {
+ // first bit of 1 byte utf-8 character is always 0
+ if (c >> 7 == 1)
+ continue;
+
+ if (std::string(1, c).find_first_not_of("1234567890.") !=
+ std::string::npos) {
+ LOG(ERROR) << "Invalid version format";
+ return nullptr;
+ }
+ }
+ return manifest_version;
}
bool StepParse::FillInstallationInfo(manifest_x* manifest) {