Fix GetPackageVersion() 68/60868/2 accepted/tizen/common/20160304.194341 accepted/tizen/ivi/20160303.093924 accepted/tizen/mobile/20160303.093812 accepted/tizen/tv/20160303.093834 accepted/tizen/wearable/20160303.093905 submit/tizen/20160303.064856
authorTomasz Iwanek <t.iwanek@samsung.com>
Wed, 2 Mar 2016 15:13:41 +0000 (16:13 +0100)
committerTomasz Iwanek <t.iwanek@samsung.com>
Wed, 2 Mar 2016 15:20:30 +0000 (16:20 +0100)
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
src/wgt/step/step_parse.h

index 705dc95..cb77e28 100644 (file)
@@ -11,6 +11,7 @@
 #include <common/installer_context.h>
 #include <common/step/step.h>
 #include <common/utils/glist_range.h>
+#include <manifest_parser/utils/version_number.h>
 #include <wgt_manifest_handlers/account_handler.h>
 #include <wgt_manifest_handlers/app_control_handler.h>
 #include <wgt_manifest_handlers/application_icons_handler.h>
@@ -95,11 +96,24 @@ std::set<std::string> 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) {
index 0737b9d..06956b0 100644 (file)
@@ -45,7 +45,7 @@ class StepParse : public common_installer::Step {
   std::set<std::string> ExtractPrivileges(
       std::shared_ptr<const PermissionsInfo> 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);