From 115bd6da57cfb8a4d1860dc82be4424c2b54ab95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 14 Sep 2016 18:45:32 +0200 Subject: [PATCH] Fix missing string encoding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks to Jérémie Simon for reporting it. --- .../public/app/tabs/users-tab/datatable.js | 2 +- .../app/tabs/vms-tab/panels/template.js | 21 +++--------- .../app/tabs/vms-tab/panels/template/html.hbs | 32 +++++++++++++++++++ .../tabs/vms-tab/utils/datatable-common.js | 2 +- 4 files changed, 39 insertions(+), 18 deletions(-) create mode 100644 src/sunstone/public/app/tabs/vms-tab/panels/template/html.hbs diff --git a/src/sunstone/public/app/tabs/users-tab/datatable.js b/src/sunstone/public/app/tabs/users-tab/datatable.js index 0f57b5952d..20b51ca558 100644 --- a/src/sunstone/public/app/tabs/users-tab/datatable.js +++ b/src/sunstone/public/app/tabs/users-tab/datatable.js @@ -139,7 +139,7 @@ define(function(require) { } // Build hidden user template - var hidden_template = TemplateUtils.templateToString(element); + var hidden_template = TemplateUtils.htmlEncode(TemplateUtils.templateToString(element)); var search = { NAME: element.NAME, diff --git a/src/sunstone/public/app/tabs/vms-tab/panels/template.js b/src/sunstone/public/app/tabs/vms-tab/panels/template.js index bd95dda269..329257cc33 100644 --- a/src/sunstone/public/app/tabs/vms-tab/panels/template.js +++ b/src/sunstone/public/app/tabs/vms-tab/panels/template.js @@ -22,6 +22,7 @@ define(function(require) { var Locale = require('utils/locale'); var Humanize = require('utils/humanize'); var TemplateUtils = require('utils/template-utils'); + var TemplateHtml = require('hbs!./template/html'); /* CONSTANTS @@ -56,22 +57,10 @@ define(function(require) { */ function _html() { - return '
'+ - '
'+ - '
' + Locale.tr("User template") + '
'+ - '
'+
-            TemplateUtils.templateToString(this.element.USER_TEMPLATE)+
-          '
'+ - '
'+ - '
'+ - '
'+ - '
'+ - '
' + Locale.tr("Template") + '
'+ - '
'+
-            TemplateUtils.templateToString(this.element.TEMPLATE)+
-          '
'+ - '
'+ - '
'; + return TemplateHtml({ + userTemplateString: TemplateUtils.templateToString(this.element.USER_TEMPLATE), + templateString: TemplateUtils.templateToString(this.element.TEMPLATE) + }); } function _setup(context) { diff --git a/src/sunstone/public/app/tabs/vms-tab/panels/template/html.hbs b/src/sunstone/public/app/tabs/vms-tab/panels/template/html.hbs new file mode 100644 index 0000000000..0eb64a2cfa --- /dev/null +++ b/src/sunstone/public/app/tabs/vms-tab/panels/template/html.hbs @@ -0,0 +1,32 @@ +{{! -------------------------------------------------------------------------- }} +{{! Copyright 2002-2016, OpenNebula Project, OpenNebula Systems }} +{{! }} +{{! Licensed under the Apache License, Version 2.0 (the "License"); you may }} +{{! not use this file except in compliance with the License. You may obtain }} +{{! a copy of the License at }} +{{! }} +{{! http://www.apache.org/licenses/LICENSE-2.0 }} +{{! }} +{{! Unless required by applicable law or agreed to in writing, software }} +{{! distributed under the License is distributed on an "AS IS" BASIS, }} +{{! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }} +{{! See the License for the specific language governing permissions and }} +{{! limitations under the License. }} +{{! -------------------------------------------------------------------------- }} + +
+
+
{{tr "User template"}}
+
+      {{~userTemplateString~}}
+    
+
+
+
+
+
{{tr "Template"}}
+
+      {{~templateString~}}
+    
+
+
\ No newline at end of file diff --git a/src/sunstone/public/app/tabs/vms-tab/utils/datatable-common.js b/src/sunstone/public/app/tabs/vms-tab/utils/datatable-common.js index 91b220ce04..2e37bd3378 100644 --- a/src/sunstone/public/app/tabs/vms-tab/utils/datatable-common.js +++ b/src/sunstone/public/app/tabs/vms-tab/utils/datatable-common.js @@ -124,7 +124,7 @@ define(function(require) { OpenNebulaVM.ipsStr(element), Humanize.prettyTime(element.STIME), vncIcon, - TemplateUtils.templateToString(element), + TemplateUtils.htmlEncode(TemplateUtils.templateToString(element)), (LabelsUtils.labelsStr(element[TEMPLATE_ATTR])||''), btoa(unescape(encodeURIComponent(JSON.stringify(search)))) ];