From 67ce999e6a24c025fb7c8b695cb884aa0057c809 Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Wed, 2 Mar 2016 16:13:41 +0100 Subject: [PATCH] Fix GetPackageVersion() Version of widget (defined in w3c spec) is less strict than tizen package number. This commit fixes GetPackageVersion() to set default version if conversion of version number is not possible. To verify, install/update wgt package which version is "1.2.3 Beta". "Beta" keyword should be trucated so that manifest contains valid version of tizen package -> "1.2.3". Change-Id: Iab5eed29f8cb7c8a0a52cb515c16ce0ab5d1ac91 --- src/wgt/step/step_parse.cc | 22 ++++++++++++++++++---- src/wgt/step/step_parse.h | 2 +- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/wgt/step/step_parse.cc b/src/wgt/step/step_parse.cc index 705dc95..cb77e28 100644 --- a/src/wgt/step/step_parse.cc +++ b/src/wgt/step/step_parse.cc @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -95,11 +96,24 @@ std::set StepParse::ExtractPrivileges( return perm_info->GetAPIPermissions(); } -const std::string& StepParse::GetPackageVersion( +std::string StepParse::GetPackageVersion( const std::string& manifest_version) { - if (!manifest_version.empty()) - return manifest_version; - return kManifestVersion; + if (manifest_version.empty()) { + return kManifestVersion; + } + std::string version = manifest_version.substr(0, + manifest_version.find_first_not_of("1234567890.")); + + utils::VersionNumber version_number(version); + + if (!version_number.IsValidTizenPackageVersion()) { + LOG(WARNING) << "Version number: " << manifest_version + << " is not valid version number for tizen package. " + << "Default value will be used."; + return kManifestVersion; + } + + return version_number.ToString(); } bool StepParse::FillInstallationInfo(manifest_x* manifest) { diff --git a/src/wgt/step/step_parse.h b/src/wgt/step/step_parse.h index 0737b9d..06956b0 100644 --- a/src/wgt/step/step_parse.h +++ b/src/wgt/step/step_parse.h @@ -45,7 +45,7 @@ class StepParse : public common_installer::Step { std::set ExtractPrivileges( std::shared_ptr perm_info) const; - const std::string& GetPackageVersion(const std::string& manifest_version); + std::string GetPackageVersion(const std::string& manifest_version); bool FillInstallationInfo(manifest_x* manifest); bool FillIconPaths(manifest_x* manifest); -- 2.7.4