diff --git a/luigi/static/visualiser/index.html b/luigi/static/visualiser/index.html
index 9c433bb25e..63052a5e10 100644
--- a/luigi/static/visualiser/index.html
+++ b/luigi/static/visualiser/index.html
@@ -16,6 +16,7 @@
+
diff --git a/luigi/static/visualiser/js/graph.js b/luigi/static/visualiser/js/graph.js
index b1ce4c4023..e646e4e025 100644
--- a/luigi/static/visualiser/js/graph.js
+++ b/luigi/static/visualiser/js/graph.js
@@ -269,7 +269,7 @@ Graph = (function() {
$(svgLink(node.trackingUrl))
.append(
$(svgElement("text"))
- .text(node.name)
+ .text(escapeHtml(node.name))
.attr("y", 3))
.attr("class","graph-node-a")
.attr("data-task-status", node.status)
@@ -284,7 +284,7 @@ Graph = (function() {
container: 'body',
html: true,
placement: 'top',
- content: content
+ content: escapeHtml(content)
});
});
@@ -313,7 +313,7 @@ Graph = (function() {
.appendTo(legend);
$(svgElement("text"))
- .text(key.charAt(0).toUpperCase() + key.substring(1).toLowerCase().replace(/_./gi, function (x) { return " " + x[1].toUpperCase(); }))
+ .text(escapeHtml(key.charAt(0).toUpperCase() + key.substring(1).toLowerCase().replace(/_./gi, function (x) { return " " + x[1].toUpperCase(); })))
.attr("x", legendLineHeight + 14)
.attr("y", legendLineHeight+(x*legendLineHeight))
.appendTo(legend);
diff --git a/luigi/static/visualiser/js/util.js b/luigi/static/visualiser/js/util.js
new file mode 100644
index 0000000000..9a693e515f
--- /dev/null
+++ b/luigi/static/visualiser/js/util.js
@@ -0,0 +1,8 @@
+function escapeHtml(unsafe) {
+ return unsafe
+ .replace(/&/g, "&")
+ .replace(//g, ">")
+ .replace(/"/g, """)
+ .replace(/'/g, "'");
+}
diff --git a/luigi/static/visualiser/js/visualiserApp.js b/luigi/static/visualiser/js/visualiserApp.js
index 83de46b9ba..156106d714 100644
--- a/luigi/static/visualiser/js/visualiserApp.js
+++ b/luigi/static/visualiser/js/visualiserApp.js
@@ -1018,8 +1018,8 @@ function visualiserApp(luigi) {
function renderParams(params) {
var htmls = [];
for (var key in params) {
- htmls.push('' + key +
- '=' + params[key] + '');
+ htmls.push('' + escapeHtml(key) +
+ '=' + escapeHtml(params[key]) + '');
}
return htmls.join(', ');
}