From 8cbdfe07c9ba68836bce53fcb6e65c6fbfae70a2 Mon Sep 17 00:00:00 2001 From: nit Date: Thu, 21 Apr 2011 16:37:53 +0530 Subject: [PATCH] bug 8803: Allow to add an ISO with URL that doesn't end with ".iso". The check checks that the url path should end with an iso status 8803: resolved fixed --- server/src/com/cloud/template/TemplateManagerImpl.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java index 64e647dbe71..1d068835746 100755 --- a/server/src/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/com/cloud/template/TemplateManagerImpl.java @@ -224,9 +224,15 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe if (!isAdmin && zoneId == null) { throw new InvalidParameterValueException("Please specify a valid zone Id."); } - + String urlPath = ""; + try { + urlPath = (new URI(url)).getPath(); + } catch (URISyntaxException e) { + throw new IllegalArgumentException("Invalid URL " + url); + } if((!url.toLowerCase().endsWith("iso"))&&(!url.toLowerCase().endsWith("iso.zip"))&&(!url.toLowerCase().endsWith("iso.bz2")) - &&(!url.toLowerCase().endsWith("iso.gz"))){ + &&(!url.toLowerCase().endsWith("iso.gz")) + &&(!(urlPath.endsWith("iso")))){ throw new InvalidParameterValueException("Please specify a valid iso"); }