//allowed: a-z, A-Z, 0-9
const char* REG_TIZENID_PATTERN = "^[a-zA-Z0-9]{10}.{1,}$";
+const char* REG_NAME_PATTERN = "^[a-zA-Z0-9._-]{1,}$";
const size_t PACKAGE_ID_LENGTH = 10;
static const DPL::String SETTING_VALUE_ENCRYPTION = L"encryption";
break;
}
}
- if (!!name) {
- LogDebug("Name : " << name);
- std::ostringstream appid;
- appid << m_installerContext.widgetConfig.tzPkgid << "." << name;
- LogDebug("tizen appid was generated by WRT : " << appid.str());
- m_installerContext.widgetConfig.tzAppid =
- DPL::FromUTF8String(appid.str());
- } else {
- m_installerContext.widgetConfig.tzAppid =
- m_installerContext.widgetConfig.tzPkgid;
+ regex_t regx;
+ if(regcomp(®x, REG_NAME_PATTERN, REG_NOSUB | REG_EXTENDED)!=0){
+ LogDebug("Regcomp failed");
}
- DPL::OptionalString appid = m_installerContext.widgetConfig.tzAppid;
+
+ if (!name || (regexec(®x, DPL::ToUTF8String(*name).c_str(),
+ static_cast<size_t>(0), NULL, 0) != REG_NOERROR)) {
+ // TODO : generate name move to wrt-commons
+ std::string allowedString("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
+ std::ostringstream genName;
+
+ genName << "_" << allowedString[rand() % allowedString.length()];
+ name = DPL::FromUTF8String(genName.str());
+ LogDebug("name was generated by WRT" );
+ }
+ regfree(®x);
+ LogDebug("Name : " << name);
+ std::ostringstream genid;
+ genid << m_installerContext.widgetConfig.tzPkgid << "." << name;
+ LogDebug("tizen appid was generated by WRT : " << genid.str());
+
+ DPL::OptionalString appid = DPL::FromUTF8String(genid.str());
NormalizeAndTrimSpaceString(appid);
m_installerContext.widgetConfig.tzAppid = *appid;
}