Check the parsed theme is valid or not 93/236193/1
authorSangyoon Jang <jeremy.jang@samsung.com>
Mon, 15 Jun 2020 11:17:45 +0000 (20:17 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Mon, 15 Jun 2020 11:17:45 +0000 (20:17 +0900)
Change-Id: I03b047f7abd1bd5fcf452bd6c106feb6f70faaa5
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/theme_plugin/theme_metadata_plugin.cc

index eadf073..d004781 100644 (file)
@@ -51,8 +51,12 @@ bool InstallTheme(const std::string& id, const std::string& pkgid,
     return false;
   }
   ttm::plugin::ThemeParser parser(path);
-  if (!parser.Commit(ttm::plugin::ThemeParser::ThemeOperation::ADD,
-      parser.Inflate(id, pkgid, uid)))
+  ttm::loader::ThemeInfo theme = parser.Inflate(id, pkgid, uid);
+  if (!theme.IsValid()) {
+    LOG(ERROR) << "Failed to parse theme";
+    return false;
+  }
+  if (!parser.Commit(ttm::plugin::ThemeParser::ThemeOperation::ADD, theme))
     return false;
   return true;
 }
@@ -81,8 +85,12 @@ bool UpgradeTheme(const std::string& id, const std::string& pkgid,
     return false;
   }
   ttm::plugin::ThemeParser parser(path);
-  if (!parser.Commit(ttm::plugin::ThemeParser::ThemeOperation::UPDATE,
-      parser.Inflate(id, pkgid, uid)))
+    ttm::loader::ThemeInfo theme = parser.Inflate(id, pkgid, uid);
+  if (!theme.IsValid()) {
+    LOG(ERROR) << "Failed to parse theme";
+    return false;
+  }
+  if (!parser.Commit(ttm::plugin::ThemeParser::ThemeOperation::UPDATE, theme))
     return false;
   return true;
 }
@@ -111,8 +119,12 @@ bool UninstallTheme(const std::string& id, const std::string& pkgid,
     return false;
   }
   ttm::plugin::ThemeParser parser(path);
-  if (!parser.Commit(ttm::plugin::ThemeParser::ThemeOperation::REMOVE,
-      parser.Inflate(id, pkgid, uid)))
+  ttm::loader::ThemeInfo theme = parser.Inflate(id, pkgid, uid);
+  if (!theme.IsValid()) {
+    LOG(ERROR) << "Failed to parse theme";
+    return false;
+  }
+  if (!parser.Commit(ttm::plugin::ThemeParser::ThemeOperation::REMOVE, theme))
     return false;
   return true;
 }