cloudstack 3.0 UI - replace old sanitizeXSS() with new cloudStack.sanitize().

This commit is contained in:
Jessica Wang 2012-03-14 14:03:28 -07:00
parent dd55f8ab99
commit 4b4cba10c7
6 changed files with 42 additions and 36 deletions

View File

@ -1634,7 +1634,7 @@
return "Unlimited";
}
else {
return fromdb(args) + " Mb/s";
return _s(args) + " Mb/s";
}
}

View File

@ -1645,7 +1645,7 @@
var jsonObj = args.context.instances[0];
args.response.success({
data: {
totalCPU: fromdb(jsonObj.cpunumber) + " x " + cloudStack.converters.convertHz(jsonObj.cpuspeed),
totalCPU: _s(jsonObj.cpunumber) + " x " + cloudStack.converters.convertHz(jsonObj.cpuspeed),
cpuused: jsonObj.cpuused,
networkkbsread: (jsonObj.networkkbsread == null || jsonObj.networkkbsread == 0)? "N/A": cloudStack.converters.convertBytes(jsonObj.networkkbsread * 1024),
networkkbswrite: (jsonObj.networkkbswrite == null || jsonObj.networkkbswrite == 0)? "N/A": cloudStack.converters.convertBytes(jsonObj.networkkbswrite * 1024)

View File

@ -91,21 +91,26 @@ function createURL(apiName, options) {
return urlString;
}
/*
function fromdb(val) {
return sanitizeXSS(noNull(val));
}
*/
function todb(val) {
return encodeURIComponent(val);
}
/*
function noNull(val) {
if(val == null)
return "";
else
return val;
}
*/
/*
function sanitizeXSS(val) { // Prevent cross-site-script(XSS) attack
if(val == null || typeof(val) != "string")
return val;
@ -113,6 +118,7 @@ function sanitizeXSS(val) { // Prevent cross-site-script(XSS) attack
val = val.replace(/>/g, ">"); //replace > whose unicode is \u003e
return unescape(val);
}
*/
// Role Functions
function isAdmin() {
@ -148,7 +154,7 @@ function handleError(XMLHttpResponse, handleErrorCallback) {
}
else {
var errorMsg = parseXMLHttpResponse(XMLHttpResponse);
$("#dialog_error").text(fromdb(errorMsg)).dialog("open");
$("#dialog_error").text(_s(errorMsg)).dialog("open");
}
}
@ -163,7 +169,7 @@ function parseXMLHttpResponse(XMLHttpResponse) {
var property;
for(property in json) {}
var errorObj = json[property];
return fromdb(errorObj.errortext);
return _s(errorObj.errortext);
} else {
return "";
}
@ -439,13 +445,13 @@ function iscsiURL(server, iqn, lun) {
//VM Instance
function getVmName(p_vmName, p_vmDisplayname) {
if(p_vmDisplayname == null)
return fromdb(p_vmName);
return _s(p_vmName);
var vmName = null;
if (p_vmDisplayname != p_vmName) {
vmName = fromdb(p_vmName) + " (" + fromdb(p_vmDisplayname) + ")";
vmName = _s(p_vmName) + " (" + _s(p_vmDisplayname) + ")";
} else {
vmName = fromdb(p_vmName);
vmName = _s(p_vmName);
}
return vmName;
}

View File

@ -2441,7 +2441,7 @@
addExternalLoadBalancer(args, selectedPhysicalNetworkObj, "addNetscalerLoadBalancer", "addnetscalerloadbalancerresponse", "netscalerloadbalancer");
}
else if (result.jobstatus == 2) {
alert("addNetworkServiceProvider&name=Netscaler failed. Error: " + fromdb(result.jobresult.errortext));
alert("addNetworkServiceProvider&name=Netscaler failed. Error: " + _s(result.jobresult.errortext));
}
}
},
@ -2660,7 +2660,7 @@
addExternalLoadBalancer(args, selectedPhysicalNetworkObj, "addF5LoadBalancer", "addf5bigiploadbalancerresponse");
}
else if (result.jobstatus == 2) {
alert("addNetworkServiceProvider&name=F5BigIp failed. Error: " + fromdb(result.jobresult.errortext));
alert("addNetworkServiceProvider&name=F5BigIp failed. Error: " + _s(result.jobresult.errortext));
}
}
},
@ -2900,7 +2900,7 @@
addExternalFirewall(args, selectedPhysicalNetworkObj, "addSrxFirewall", "addsrxfirewallresponse", "srxfirewall");
}
else if (result.jobstatus == 2) {
alert("addNetworkServiceProvider&name=JuniperSRX failed. Error: " + fromdb(result.jobresult.errortext));
alert("addNetworkServiceProvider&name=JuniperSRX failed. Error: " + _s(result.jobresult.errortext));
}
}
},
@ -3902,7 +3902,7 @@
addExternalLoadBalancer(args, selectedPhysicalNetworkObj, "addNetscalerLoadBalancer", "addnetscalerloadbalancerresponse", "netscalerloadbalancer");
}
else if (result.jobstatus == 2) {
alert("addNetworkServiceProvider&name=Netscaler failed. Error: " + fromdb(result.jobresult.errortext));
alert("addNetworkServiceProvider&name=Netscaler failed. Error: " + _s(result.jobresult.errortext));
}
}
},
@ -4085,7 +4085,7 @@
addExternalLoadBalancer(args, selectedPhysicalNetworkObj, "addF5LoadBalancer", "addf5bigiploadbalancerresponse", "f5loadbalancer");
}
else if (result.jobstatus == 2) {
alert("addNetworkServiceProvider&name=F5BigIp failed. Error: " + fromdb(result.jobresult.errortext));
alert("addNetworkServiceProvider&name=F5BigIp failed. Error: " + _s(result.jobresult.errortext));
}
}
},
@ -4290,7 +4290,7 @@
addExternalFirewall(args, selectedPhysicalNetworkObj, "addSrxFirewall", "addsrxfirewallresponse", "srxfirewall");
}
else if (result.jobstatus == 2) {
alert("addNetworkServiceProvider&name=JuniperSRX failed. Error: " + fromdb(result.jobresult.errortext));
alert("addNetworkServiceProvider&name=JuniperSRX failed. Error: " + _s(result.jobresult.errortext));
}
}
},
@ -5695,7 +5695,7 @@
var jsonObj = args.context.hosts[0];
args.response.success({
data: {
totalCPU: fromdb(jsonObj.cpunumber) + " x " + cloudStack.converters.convertHz(jsonObj.cpuspeed),
totalCPU: _s(jsonObj.cpunumber) + " x " + cloudStack.converters.convertHz(jsonObj.cpuspeed),
cpuused: jsonObj.cpuused,
cpuallocated: (jsonObj.cpuallocated == null || jsonObj.cpuallocated == 0)? "N/A": jsonObj.cpuallocated,
memorytotal: (jsonObj.memorytotal == null || jsonObj.memorytotal == 0)? "N/A": cloudStack.converters.convertBytes(jsonObj.memorytotal * 1024),
@ -7066,7 +7066,7 @@
});
}
else if (result.jobstatus == 2) {
alert("failed to enable security group provider. Error: " + fromdb(result.jobresult.errortext));
alert("failed to enable security group provider. Error: " + _s(result.jobresult.errortext));
}
}
},
@ -7147,7 +7147,7 @@
}
}
else if (result.jobstatus == 2) {
alert("failed to enable Virtual Router Provider. Error: " + fromdb(result.jobresult.errortext));
alert("failed to enable Virtual Router Provider. Error: " + _s(result.jobresult.errortext));
}
}
},
@ -7161,7 +7161,7 @@
});
}
else if (result.jobstatus == 2) {
alert("configureVirtualRouterElement failed. Error: " + fromdb(result.jobresult.errortext));
alert("configureVirtualRouterElement failed. Error: " + _s(result.jobresult.errortext));
}
}
},
@ -7175,7 +7175,7 @@
});
}
else if (result.jobstatus == 2) {
alert("updatePhysicalNetwork failed. Error: " + fromdb(result.jobresult.errortext));
alert("updatePhysicalNetwork failed. Error: " + _s(result.jobresult.errortext));
}
}
},

View File

@ -93,7 +93,7 @@
cloudStack.dialog.notice({ message: 'Update SSL Certiciate succeeded' });
}
else if (result.jobstatus == 2) {
cloudStack.dialog.notice({ message: 'Failed to update SSL Certificate. ' + fromdb(result.jobresult.errortext) });
cloudStack.dialog.notice({ message: 'Failed to update SSL Certificate. ' + _s(result.jobresult.errortext) });
}
$loading.remove();
}

View File

@ -1106,7 +1106,7 @@
}
}
else if (result.jobstatus == 2) {
alert("Failed to add Guest traffic type to basic zone. Error: " + fromdb(result.jobresult.errortext));
alert("Failed to add Guest traffic type to basic zone. Error: " + _s(result.jobresult.errortext));
}
}
},
@ -1150,7 +1150,7 @@
}
}
else if (result.jobstatus == 2) {
alert("Failed to add Management traffic type to basic zone. Error: " + fromdb(result.jobresult.errortext));
alert("Failed to add Management traffic type to basic zone. Error: " + _s(result.jobresult.errortext));
}
}
},
@ -1195,7 +1195,7 @@
}
}
else if (result.jobstatus == 2) {
alert("Failed to add Public traffic type to basic zone. Error: " + fromdb(result.jobresult.errortext));
alert("Failed to add Public traffic type to basic zone. Error: " + _s(result.jobresult.errortext));
}
}
},
@ -1210,7 +1210,7 @@
}
}
else if (result.jobstatus == 2) {
alert("createPhysicalNetwork failed. Error: " + fromdb(result.jobresult.errortext));
alert("createPhysicalNetwork failed. Error: " + _s(result.jobresult.errortext));
}
}
},
@ -1294,7 +1294,7 @@
}
}
else if (result.jobstatus == 2) {
alert(apiCmd + " failed. Error: " + fromdb(result.jobresult.errortext));
alert(apiCmd + " failed. Error: " + _s(result.jobresult.errortext));
}
}
},
@ -1309,7 +1309,7 @@
});
}
else if (result.jobstatus == 2) {
alert("createPhysicalNetwork failed. Error: " + fromdb(result.jobresult.errortext));
alert("createPhysicalNetwork failed. Error: " + _s(result.jobresult.errortext));
}
}
},
@ -1495,7 +1495,7 @@
});
}
else if (result.jobstatus == 2) {
alert("addNetworkServiceProvider&name=Netscaler failed. Error: " + fromdb(result.jobresult.errortext));
alert("addNetworkServiceProvider&name=Netscaler failed. Error: " + _s(result.jobresult.errortext));
}
}
},
@ -1532,7 +1532,7 @@
}
}
else if (result.jobstatus == 2) {
alert("failed to enable security group provider. Error: " + fromdb(result.jobresult.errortext));
alert("failed to enable security group provider. Error: " + _s(result.jobresult.errortext));
}
}
},
@ -1568,7 +1568,7 @@
}
}
else if (result.jobstatus == 2) {
alert("failed to enable Virtual Router Provider. Error: " + fromdb(result.jobresult.errortext));
alert("failed to enable Virtual Router Provider. Error: " + _s(result.jobresult.errortext));
}
}
},
@ -1582,7 +1582,7 @@
});
}
else if (result.jobstatus == 2) {
alert("configureVirtualRouterElement failed. Error: " + fromdb(result.jobresult.errortext));
alert("configureVirtualRouterElement failed. Error: " + _s(result.jobresult.errortext));
}
}
},
@ -1596,7 +1596,7 @@
});
}
else if (result.jobstatus == 2) {
alert("updatePhysicalNetwork failed. Error: " + fromdb(result.jobresult.errortext));
alert("updatePhysicalNetwork failed. Error: " + _s(result.jobresult.errortext));
}
}
},
@ -1713,7 +1713,7 @@
}
}
else if (result.jobstatus == 2) {
alert("failed to enable Virtual Router Provider. Error: " + fromdb(result.jobresult.errortext));
alert("failed to enable Virtual Router Provider. Error: " + _s(result.jobresult.errortext));
}
}
},
@ -1727,7 +1727,7 @@
});
}
else if (result.jobstatus == 2) {
alert("configureVirtualRouterElement failed. Error: " + fromdb(result.jobresult.errortext));
alert("configureVirtualRouterElement failed. Error: " + _s(result.jobresult.errortext));
}
}
},
@ -1741,7 +1741,7 @@
});
}
else if (result.jobstatus == 2) {
alert("updatePhysicalNetwork failed. Error: " + fromdb(result.jobresult.errortext));
alert("updatePhysicalNetwork failed. Error: " + _s(result.jobresult.errortext));
}
}
},
@ -1910,7 +1910,7 @@
});
}
else if(result.jobstatus == 2) {
alert("failed to enable Netscaler provider. Error: " + fromdb(result.jobresult.errortext));
alert("failed to enable Netscaler provider. Error: " + _s(result.jobresult.errortext));
}
}
}
@ -1924,7 +1924,7 @@
});
}
else if(result.jobstatus == 2) { //addNetscalerLoadBalancer failed
error('addNetscalerDevice', fromdb(result.jobresult.errortext), { fn: 'addNetscalerDevice', args: args });
error('addNetscalerDevice', _s(result.jobresult.errortext), { fn: 'addNetscalerDevice', args: args });
}
}
}
@ -2224,7 +2224,7 @@
}
}
else if(result.jobstatus == 2){
alert("error: " + fromdb(result.jobresult.errortext));
alert("error: " + _s(result.jobresult.errortext));
}
}
},