diff --git a/src/sunstone/public/js/plugins/oneflow-templates.js b/src/sunstone/public/js/plugins/oneflow-templates.js index 5e22eb559a..3c49c79e7b 100644 --- a/src/sunstone/public/js/plugins/oneflow-templates.js +++ b/src/sunstone/public/js/plugins/oneflow-templates.js @@ -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'])); } }) } diff --git a/src/sunstone/public/js/plugins/templates-tab.js b/src/sunstone/public/js/plugins/templates-tab.js index 94db583330..d7e74cdabf 100644 --- a/src/sunstone/public/js/plugins/templates-tab.js +++ b/src/sunstone/public/js/plugins/templates-tab.js @@ -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 $('
').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; } diff --git a/src/sunstone/public/js/sunstone.js b/src/sunstone/public/js/sunstone.js index 9f5294e94a..3bf824139e 100644 --- a/src/sunstone/public/js/sunstone.js +++ b/src/sunstone/public/js/sunstone.js @@ -2589,8 +2589,8 @@ function loadAccounting(resource, id, graphs, options){ }; } -var unscape = function(convert){ - return $("", { html: convert }).text(); +function htmlDecode(value){ + return $('').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)