Skip to content

Commit c4c68e2

Browse files
author
Jessica Wang
committed
cloudstack 3.0 UI - fix a JS error "str.replace is undefined".
1 parent 4b4cba1 commit c4c68e2

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

‎ui/scripts/instances.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1645,7 +1645,7 @@
16451645
var jsonObj = args.context.instances[0];
16461646
args.response.success({
16471647
data: {
1648-
totalCPU: _s(jsonObj.cpunumber) + " x " + cloudStack.converters.convertHz(jsonObj.cpuspeed),
1648+
totalCPU: jsonObj.cpunumber + " x " + cloudStack.converters.convertHz(jsonObj.cpuspeed),
16491649
cpuused: jsonObj.cpuused,
16501650
networkkbsread: (jsonObj.networkkbsread == null || jsonObj.networkkbsread == 0)? "N/A": cloudStack.converters.convertBytes(jsonObj.networkkbsread * 1024),
16511651
networkkbswrite: (jsonObj.networkkbswrite == null || jsonObj.networkkbswrite == 0)? "N/A": cloudStack.converters.convertBytes(jsonObj.networkkbswrite * 1024)

‎ui/scripts/system.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5695,7 +5695,7 @@
56955695
var jsonObj = args.context.hosts[0];
56965696
args.response.success({
56975697
data: {
5698-
totalCPU: _s(jsonObj.cpunumber) + " x " + cloudStack.converters.convertHz(jsonObj.cpuspeed),
5698+
totalCPU: jsonObj.cpunumber + " x " + cloudStack.converters.convertHz(jsonObj.cpuspeed),
56995699
cpuused: jsonObj.cpuused,
57005700
cpuallocated: (jsonObj.cpuallocated == null || jsonObj.cpuallocated == 0)? "N/A": jsonObj.cpuallocated,
57015701
memorytotal: (jsonObj.memorytotal == null || jsonObj.memorytotal == 0)? "N/A": cloudStack.converters.convertBytes(jsonObj.memorytotal * 1024),

‎ui/scripts/ui/utils.js‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,24 @@
6060
*
6161
* Strip unwanted characters from user-based input
6262
*/
63-
cloudStack.sanitize = window._s = function(str) {
64-
if (!str) return '';
65-
66-
var sanitized = str
63+
cloudStack.sanitize = window._s = function(value) {
64+
if(typeof(value) == "number") {
65+
//alert("number does not need to be sanitized. Only string needs to be sanitized.");
66+
return value;
67+
}
68+
else if(typeof(value) == "boolean") {
69+
//alert("boolean does not need to be sanitized. Only string needs to be sanitized.");
70+
return value;
71+
}
72+
else if(typeof(value) == "object") {
73+
//alert("object cant not be sanitized. Only string can be sanitized.");
74+
return value;
75+
}
76+
else if(typeof(value) == null || typeof(value) == "undefined") {
77+
return '';
78+
}
79+
80+
var sanitized = value
6781
.replace(/&/g, "&")
6882
.replace(/</g, "&lt;")
6983
.replace(/>/g, "&gt;");

0 commit comments

Comments
 (0)