//allowed: a-z, A-Z, 0-9
const char* REG_TIZENID_PATTERN = "^[a-zA-Z0-9]{10}.{1,}$";
+const char* REG_PKGID_PATTERN = "^[a-zA-Z0-9]{10}$";
const char* REG_NAME_PATTERN = "^[a-zA-Z0-9._-]{1,}$";
const size_t PACKAGE_ID_LENGTH = 10;
regex_t reg;
if (regcomp(®, REG_TIZENID_PATTERN, REG_NOSUB | REG_EXTENDED) != 0) {
_D("Regcomp failed");
+ return false;
}
if (regexec(®, DPL::ToUTF8String(tizenAppId).c_str(), 0, NULL, 0)
bool TaskConfiguration::validateTizenPackageID(
const WrtDB::TizenPkgId &tizenPkgId)
{
- std::string pkgId = DPL::ToUTF8String(tizenPkgId);
-
- std::string installPath =
- std::string(GlobalConfig::GetUserInstalledWidgetPath()) +
- "/" + pkgId;
+ _D("tizen application ID = [%ls]", tizenPkgId.c_str());
- struct stat dirStat;
- if ((stat(installPath.c_str(), &dirStat) == 0))
+ regex_t reg;
+ if (regcomp(®, REG_PKGID_PATTERN, REG_NOSUB | REG_EXTENDED) != 0)
{
+ _D("Regcomp failed");
return false;
}
+ if (regexec(®, DPL::ToUTF8String(tizenPkgId).c_str(), 0, NULL, 0) == REG_NOMATCH)
+ {
+ regfree(®);
+ return false;
+ }
+ regfree(®);
return true;
}