1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

Bug #2800: Fix template and service template update for inputs containing < or >

This commit is contained in:
Carlos Martín 2014-03-27 19:15:46 +01:00
parent 4f76320fbd
commit 6a5de1f491
3 changed files with 36 additions and 40 deletions

View File

@ -1309,7 +1309,7 @@ function fillUpUpdateServiceTemplateDialog(request, response){
var service_template = response[ServiceTemplate.resource]
$("#service_name", dialog).attr("disabled", "disabled");
$("#service_name", dialog).val(service_template.NAME);
$("#service_name", dialog).val(htmlDecode(service_template.NAME));
// TODO Check if the template still exists
$('select[name="deployment"]', dialog).val(service_template.TEMPLATE.BODY.deployment);
@ -1322,11 +1322,11 @@ function fillUpUpdateServiceTemplateDialog(request, response){
var context = $('#roles_tabs_content .content', $create_service_template_dialog).last();
$("#role_name", context).val(value.name);
$("#role_name", context).val(htmlDecode(value.name));
$("#role_name", context).change();
roles_names.push(value.name);
$("#cardinality", context).val(value.cardinality);
$("#cardinality", context).val(htmlDecode(value.cardinality));
// The vm_template select is already initialized, but we need to select
// the template retrived from the service_template. Since the initialization
@ -1336,22 +1336,22 @@ function fillUpUpdateServiceTemplateDialog(request, response){
insertSelectOptions('div#vm_template', context, "Template", value.vm_template, false);
$("select[name='shutdown_action_role']", context).val(value.shutdown_action);
$("#min_vms", context).val(value.min_vms);
$("#max_vms", context).val(value.max_vms);
$("#cooldown", context).val(value.cooldown);
$("#min_vms", context).val(htmlDecode(value.min_vms));
$("#max_vms", context).val(htmlDecode(value.max_vms));
$("#cooldown", context).val(htmlDecode(value.cooldown));
if (value['elasticity_policies']) {
$.each(value['elasticity_policies'], function(){
$("#tf_btn_elas_policies", context).click();
var td = $("#elasticity_policies_tbody tr", context).last();
$("#type" ,td).val(this['type'])
$("#type" ,td).val(htmlDecode(this['type']));
$("#type" ,td).change();
$("#adjust" ,td).val(this['adjust'] )
$("#min_adjust_step" ,td).val(this['min_adjust_step'] || "" )
$("#expression" ,td).val(unscape(this.expression))
$("#period_number" ,td).val(this['period_number'] || "")
$("#period" ,td).val(this['period'] || "" )
$("#cooldown" ,td).val(this['cooldown'] || "" )
$("#adjust" ,td).val(htmlDecode(this['adjust'] ));
$("#min_adjust_step" ,td).val(htmlDecode(this['min_adjust_step'] || ""));
$("#expression" ,td).val(htmlDecode(this.expression))
$("#period_number" ,td).val(htmlDecode(this['period_number'] || ""));
$("#period" ,td).val(htmlDecode(this['period'] || "" ));
$("#cooldown" ,td).val(htmlDecode(this['cooldown'] || "" ));
})
}
@ -1359,17 +1359,17 @@ function fillUpUpdateServiceTemplateDialog(request, response){
$.each(value['scheduled_policies'], function(){
$("#tf_btn_sche_policies", context).click();
var td = $("#scheduled_policies_tbody tr", context).last();
$("#type", td).val(this['type'])
$("#type", td).val(htmlDecode(this['type']));
$("#type" ,td).change();
$("#adjust", td).val(this['adjust'] )
$("#min_adjust_step", td).val(this['min_adjust_step'] || "")
$("#adjust", td).val(htmlDecode(this['adjust'] ));
$("#min_adjust_step", td).val(htmlDecode(this['min_adjust_step'] || ""));
if (this['start_time']) {
$("#time_format", td).val('start_time');
$("#time", td).val(this['start_time']);
$("#time", td).val(htmlDecode(this['start_time']));
} else if (this['recurrence']) {
$("#time_format", td).val('recurrence');
$("#time", td).val(this['recurrence']);
$("#time", td).val(htmlDecode(this['recurrence']));
}
})
}

View File

@ -1677,24 +1677,24 @@ function fill_nic_tab_data(template_json, context){
var field = $("input.tcp_type[value='WHITE_PORTS_TCP']", context);
field.click();
$("#TCP_PORTS", context).val(template_json["WHITE_PORTS_TCP"]);
$("#TCP_PORTS", context).val(htmlDecode(template_json["WHITE_PORTS_TCP"]));
} else if (template_json["BLACK_PORTS_TCP"]){
var field = $("input.tcp_type[value='BLACK_PORTS_TCP']", context);
field.click();
$("#TCP_PORTS", context).val(template_json["BLACK_PORTS_TCP"]);
$("#TCP_PORTS", context).val(htmlDecode(template_json["BLACK_PORTS_TCP"]));
}
if (template_json["WHITE_PORTS_UDP"]){
var field = $("input.udp_type[value='WHITE_PORTS_UDP']", context);
field.click();
$("#UDP_PORTS", context).val(template_json["WHITE_PORTS_UDP"]);
$("#UDP_PORTS", context).val(htmlDecode(template_json["WHITE_PORTS_UDP"]));
} else if (template_json["BLACK_PORTS_UDP"]){
var field = $("input.udp_type[value='BLACK_PORTS_UDP']", context);
field.click();
$("#UDP_PORTS", context).val(template_json["BLACK_PORTS_UDP"]);
$("#UDP_PORTS", context).val(htmlDecode(template_json["BLACK_PORTS_UDP"]));
}
if (template_json["ICMP"]){
@ -3894,10 +3894,6 @@ function popUpTemplateTemplateUpdateDialog(){
function fillTemplatePopUp(template, dialog){
var use_advanced_template = false;
function htmlDecode(value){
return $('<div/>').html(value).text();
}
function autoFillInputs(template_json, context){
var params = $('.vm_param',context);
var inputs = $('input',params);
@ -4228,14 +4224,14 @@ function fillTemplatePopUp(template, dialog){
var element1 = document.createElement("input");
element1.id = "TYPE";
element1.type = "text";
element1.value = this.TYPE;
element1.value = htmlDecode(this.TYPE);
cell1.appendChild(element1);
var cell2 = row.insertCell(1);
var element2 = document.createElement("input");
element2.id = "BUS";
element2.type = "text";
element2.value = this.BUS;
element2.value = htmlDecode(this.BUS);
cell2.appendChild(element2);
@ -4273,7 +4269,7 @@ function fillTemplatePopUp(template, dialog){
$("#ssh_context", context_section).attr('checked','checked');
if (!publickey_regexp.test(value)) {
$("#ssh_public_key", context_section).val(value);
$("#ssh_public_key", context_section).val(htmlDecode(value));
}
}
else if (token_regexp.test(key)) {
@ -4283,10 +4279,10 @@ function fillTemplatePopUp(template, dialog){
$("#network_context", context_section).attr('checked','checked');
}
else if ("INIT_SCRIPTS" == key){
$("input#INIT_SCRIPTS").val(value);
$("input#INIT_SCRIPTS").val(htmlDecode(value));
}
else if ("FILES_DS" == key){
$('#FILES_DS', context_section).val(context["FILES_DS"])
$('#FILES_DS', context_section).val(htmlDecode(context["FILES_DS"]))
var files = [];
while (match = file_ds_regexp.exec(value)) {
files.push(match[1])
@ -4329,14 +4325,14 @@ function fillTemplatePopUp(template, dialog){
var element1 = document.createElement("input");
element1.id = "KEY";
element1.type = "text";
element1.value = key
element1.value = htmlDecode(key);
cell1.appendChild(element1);
var cell2 = row.insertCell(1);
var element2 = document.createElement("input");
element2.id = "VALUE";
element2.type = "text";
element2.value = value
element2.value = htmlDecode(value);
cell2.appendChild(element2);
@ -4435,7 +4431,7 @@ function fillTemplatePopUp(template, dialog){
});
}
$('input#SCHED_REQUIREMENTS', req_section).val(req);
$('input#SCHED_REQUIREMENTS', req_section).val(htmlDecode(req));
delete template.SCHED_REQUIREMENTS;
}
@ -4445,7 +4441,7 @@ function fillTemplatePopUp(template, dialog){
if (ds_req) {
ds_req = escapeDoubleQuotes(ds_req);
$('input#SCHED_DS_REQUIREMENTS', req_section).val(ds_req);
$('input#SCHED_DS_REQUIREMENTS', req_section).val(htmlDecode(ds_req));
delete template.SCHED_DS_REQUIREMENTS;
}
@ -4467,7 +4463,7 @@ function fillTemplatePopUp(template, dialog){
$('input[name="rank_select"]#loadawareRadio', req_section).click()
}
$('input#SCHED_RANK', req_section).val(rank);
$('input#SCHED_RANK', req_section).val(htmlDecode(rank));
delete template.SCHED_RANK;
}
@ -4485,7 +4481,7 @@ function fillTemplatePopUp(template, dialog){
$('input[name="ds_rank_select"]#packingDSRadio', req_section).click()
}
$('input#SCHED_DS_RANK', req_section).val(ds_rank);
$('input#SCHED_DS_RANK', req_section).val(htmlDecode(ds_rank));
delete template.SCHED_DS_RANK;
}

View File

@ -2589,8 +2589,8 @@ function loadAccounting(resource, id, graphs, options){
};
}
var unscape = function(convert){
return $("<span />", { html: convert }).text();
function htmlDecode(value){
return $('<div/>').html(value).text();
};
// Convert from hash to string
@ -2654,7 +2654,7 @@ function convert_template_to_string(template_json,unshown_values)
}
})
return unscape(template_str);
return htmlDecode(template_str);
}
// Create the extended template table (with listeners)