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

M #-: sanitize tags in handlebars forms (#4172)

Signed-off-by: Jorge Lobo <jlobo@opennebula.systems>
(cherry picked from commit dc5bcaa95a94f20fa2df08616e0b049571a4ec3a)
This commit is contained in:
Jorge Lobo 2020-02-10 17:06:47 +01:00 committed by Tino Vazquez
parent 258f3c4eb9
commit 41f9a3aa24
No known key found for this signature in database
GPG Key ID: 2FE9C32E94AEABBE
3 changed files with 13 additions and 4 deletions

View File

@ -77,14 +77,14 @@ define(function(require) {
var templateTableHTML = TemplateTable.html(strippedTemplate, RESOURCE,
Locale.tr("Attributes"));
//====
return TemplateInfo({
render = TemplateInfo({
"element": this.element,
"sunstone_template": this.element.TEMPLATE.SUNSTONE||{},
"sunstone_template": this.element.TEMPLATE.SUNSTONE || {},
"templateTableHTML": templateTableHTML,
"tabId": this.tabId,
"userCreationHTML": this.userCreation.html()
});
return render;
}
function _setup(context) {

View File

@ -17,6 +17,7 @@
define(function(require) {
var Handlebars = require('hbs/handlebars');
var Locale = require('utils/locale');
var templateUtils = require("utils/template-utils");
var valOrDefault = function(value, defaultValue, options) {
var out;
@ -24,7 +25,7 @@ define(function(require) {
if (value == undefined || ($.isPlainObject(value) && $.isEmptyObject(value))){
out = defaultValue;
} else {
out = value;
out = templateUtils.removeHTMLTags(value);
}
return new Handlebars.SafeString(out);

View File

@ -171,6 +171,14 @@ define(function(require) {
return template_json;
}
function _removeHTMLTags(string){
var rtn = string;
if(rtn){
rtn = string.replace(/<[^0-9\s=>]+>/g, '');
}
return rtn;
}
return {
"stringToTemplate": _convert_string_to_template,
"templateToString": _convert_template_to_string,