Validate tpk package and application ids 86/60286/4
authorTomasz Iwanek <t.iwanek@samsung.com>
Wed, 24 Feb 2016 15:27:16 +0000 (16:27 +0100)
committerTomasz Iwanek <t.iwanek@samsung.com>
Mon, 29 Feb 2016 09:44:03 +0000 (01:44 -0800)
Most important, they should not be composed of '/'s.

Change-Id: Ia6a9441680c5ceb05abec2defc7c9f866fd58bef

src/manifest_parser/manifest_util.cc
src/manifest_parser/manifest_util.h
src/tpk_manifest_handlers/package_handler.cc
src/tpk_manifest_handlers/service_application_handler.cc
src/tpk_manifest_handlers/ui_application_handler.cc
src/tpk_manifest_handlers/widget_application_handler.cc

index 16bd5c243ff0d440683831c1f9c243d7ad71c94c..d52bcb51e0e25dd53f2c3709fd3f42c686e53e50 100644 (file)
@@ -337,4 +337,9 @@ bool ValidateTizenPackageId(const std::string& id) {
   return std::regex_match(id, package_regex);
 }
 
+bool ValidateTizenNativeId(const std::string& id) {
+  return id.find_first_of('/') == std::string::npos;
+}
+
+
 }  // namespace parser
index 7d4ae95700f141d2146e86758ace46f22f553c4c..0fef26851bcef86f10c5a14775819e7df56454f9 100644 (file)
@@ -33,6 +33,7 @@ std::unique_ptr<DictionaryValue> LoadXMLNode(
 
 bool ValidateTizenApplicationId(const std::string& id);
 bool ValidateTizenPackageId(const std::string& id);
+bool ValidateTizenNativeId(const std::string& id);
 
 }  // namespace parser
 
index 8890f954c5e6c0c466099345da65a0afa6ac89c7..10868b2da24298d76f1f4b775908c0170dfaae95 100644 (file)
@@ -141,6 +141,11 @@ bool PackageHandler::Validate(
         "The package child element of manifest element is obligatory";
     return false;
   }
+  if (!parser::ValidateTizenNativeId(package)) {
+    *error = "The package name should be composed of alphanumeric characters "
+             "optionally separate with dots.";
+    return false;
+  }
 
   const std::string& version = app_info.version();
   if (version.empty()) {
index 4e7369032cb9c2e08f919ee1352aebf22e0e7e56..611e38b9c7552b20d4f024ec801dc47c80c582fc 100644 (file)
@@ -39,6 +39,12 @@ bool ServiceAppValidation(
              "service application element is obligatory";
     return false;
   }
+  if (!parser::ValidateTizenNativeId(item.app_info.appid())) {
+    *error = "The application id should be composed of alphanumerics "
+             "optionally separate with dots.";
+    return false;
+  }
+
   const std::string& exec = item.app_info.exec();
   if (exec.empty()) {
     *error =
index aef89d761aa5ce1ab8667aea73da5d2da4686a45..4dcaf4e3d1bfad2092c872e9f50dad7e45e43985 100644 (file)
@@ -102,6 +102,12 @@ bool UIAppValidation(const UIApplicationSingleEntry& item,
     return false;
   }
 
+  if (!parser::ValidateTizenNativeId(item.app_info.appid())) {
+    *error = "The application id should be composed of alphanumerics "
+             "optionally separate with dots.";
+    return false;
+  }
+
   const std::string& exec = item.app_info.exec();
   if (exec.empty()) {
     *error = "The exec child element of ui-application element is obligatory";
index 8a7b6e6bb398d93addab9a0544da2c3d5201f262..2ffb4762cc818a000cd217da888e13ef52e18bc9 100644 (file)
@@ -91,6 +91,12 @@ bool WidgetAppValidation(const WidgetApplicationSingleEntry& item,
     return false;
   }
 
+  if (!parser::ValidateTizenNativeId(item.app_info.appid())) {
+    *error = "The application id should be composed of alphanumerics "
+             "optionally separate with dots.";
+    return false;
+  }
+
   const std::string& exec = item.app_info.exec();
   if (exec.empty()) {
     *error = "The exec child element of widget-application element "