When using Kimchi via the UI, the browser checks whether the template
URL is valid using a regular expression. However, that regexp doesn't
match every valid URL out there and it causes problems on some browsers
(e.g. the latest Firefox ESR).
Use a simpler URL validation when creating new templates (i.e. only
validate the possible web protocols). Even if a non-existing/invalid
URL passes this validation, it will still be checked in the backend.
Fix issue #518 (Unable to download ISO to storage pool on Firefox 31.3.0
ESR).
Signed-off-by: Crístian Viana <vianac(a)linux.vnet.ibm.com>
---
ui/js/src/kimchi.template_add_main.js | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/ui/js/src/kimchi.template_add_main.js
b/ui/js/src/kimchi.template_add_main.js
index 6223c96..46c4f84 100644
--- a/ui/js/src/kimchi.template_add_main.js
+++ b/ui/js/src/kimchi.template_add_main.js
@@ -425,19 +425,9 @@ kimchi.template_add_main = function() {
};
kimchi.template_check_url = function(url) {
- var protocols = "((https|http|ftp|ftps|tftp)?://)?",
- userinfo =
"(([0-9a-z_!~*'().&=+$%-]+:)?[0-9a-z_!~*'().&=+$%-]+@)?",
- ip = "(\\d{1,3}\.){3}\\d{1,3}",
- domain =
"([0-9a-z_!~*'()-]+\.)*([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.[a-z]{2,6}",
- port = "(:\\d{1,5})?",
- address = "(/[\\w!~*'().;?:@&=+$,%#-]+)+",
- domaintype = [ protocols, userinfo, domain, port, address ],
- ipType = [ protocols, userinfo, ip, port, address ],
- validate = function(type) {
- return new RegExp('^' + type.join('') + '$');
- };
+ var reg = /(https|http|ftp|ftps|tftp):\/\//;
if (url.constructor === String) {
- return validate(domaintype).test(url) || validate(ipType).test(url);
+ return reg.test(url);
}
return false;
};
--
2.1.0
Show replies by date
Applied. Thanks.
Regards,
Aline Manera