bug 6367: registerISO, registerTemplate and createTemplate - can create non-ascii character names.

status 6367: resolved fixed
This commit is contained in:
nit 2010-11-08 20:55:02 +05:30
parent af502b1c4c
commit 70358ac153
2 changed files with 2 additions and 9 deletions

View File

@ -317,10 +317,6 @@ public class TemplateManagerImpl implements TemplateManager {
{
throw new InvalidParameterValueException("Template name should be less than 32 characters");
}
if (!name.matches("^[\\p{Alnum} ._-]+")) {
throw new InvalidParameterValueException("Only alphanumeric, dot, dashes and underscore characters allowed for the parameter 'name'");
}
ImageFormat imgfmt = ImageFormat.valueOf(format.toUpperCase());
if (imgfmt == null) {
@ -1241,7 +1237,7 @@ public class TemplateManagerImpl implements TemplateManager {
// FIXME: if template/ISO owner is null we probably need to throw some kind of exception
if (template != null) {
Account templateOwner = _accountDao.findById(template.getId());
Account templateOwner = _accountDao.findById(template.getAccountId());
if ((templateOwner != null) && !_domainDao.isChildDomain(account.getDomainId(), templateOwner.getDomainId())) {
throw new PermissionDeniedException(msg + ". Permission denied.");
}

View File

@ -2532,10 +2532,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
if ((name == null) || (name.length() > 32)) {
throw new InvalidParameterValueException("Template name cannot be null and should be less than 32 characters");
}
if (!name.matches("^[\\p{Alnum} ._-]+")) {
throw new InvalidParameterValueException("Only alphanumeric, space, dot, dashes and underscore characters allowed");
}
String uniqueName = Long.valueOf((userId == null)?1:userId).toString() + Long.valueOf(volumeId).toString() + UUID.nameUUIDFromBytes(name.getBytes()).toString();
VMTemplateVO existingTemplate = _templateDao.findByTemplateNameAccountId(name, volume.getAccountId());