B #1778: VM log doesn't escape markup characters (#1875)

(cherry picked from commit d6aaf49a68)
This commit is contained in:
Abel Coronado authored and Tino Vazquez committed 2018-03-21 18:45:28 +01:00
1 parent bb30936f02
commit 193102a271
1 file changed
+17 -7
@@ -27,10 +27,10 @@ define(function(require) {
CONSTANTS
*/
var TAB_ID = require('../tabId');
var PANEL_ID = require('./log/panelId');
var RESOURCE = "VM"
var XML_ROOT = "VM"
var TAB_ID = require("../tabId");
var PANEL_ID = require("./log/panelId");
var RESOURCE = "VM";
var XML_ROOT = "VM";
/*
CONSTRUCTOR
@@ -80,7 +80,7 @@ define(function(require) {
var log_lines = response['vm_log'].split("\n");
var colored_log = '';
for (var i = 0; i < log_lines.length; i++) {
var line = log_lines[i];
var line = escapeHtml(log_lines[i]);
if (line.match(/\[E\]/)) {
line = '<span class="vm_log_error">' + line + '</span>';
}
@@ -91,8 +91,9 @@ define(function(require) {
'<div class="row">' +
'<div class="large-11 small-centered columns log-tab">' +
colored_log +
'</div>' +
'</div>')
"</div>" +
"</div>");
$(".vm_log_container", context).animate({scrollTop: $(".vm_log_container", context).prop("scrollHeight")}, "slow");
},
error: function(request, error_json) {
@@ -109,4 +110,13 @@ define(function(require) {
}
});
}
function escapeHtml(log_line) {
return log_line
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
}
});