Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,20 @@ SignatureReport.GraphsTab.prototype.formatData = function (data) {
});
});

// By reading back innerHTML, the browser serializes the text node
// into safe HTML thus escaping special characters.
function escapeHTML(str) {
let tmpDiv = document.createElement('div');
tmpDiv.textContent = str;
return tmpDiv.innerHTML;
}

// Make the data object into an array of arrays for Metrics Graphics
// and add the associated legend in the same order.
$.each(lineDataObject, function (key, lineData) {
// The keys of lineDataObject are crash report field values
$.each(lineDataObject, function (fieldValue, lineData) {
lineDataArray.push(lineData);
legend.push(key);
legend.push(escapeHTML(fieldValue));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the one for the issue reported in the bug.

});

// Return the line data, the legend and also any remaining terms after the
Expand Down Expand Up @@ -150,7 +159,7 @@ SignatureReport.GraphsTab.prototype.drawGraph = function (graphData, contentElem
legend_target: '.new-legend',
show_secondary_x_label: false,
mouseover: function (d) {
$('.mg-active-datapoint', contentElement).html(d.term + ': ' + d.count + (d.count === 1 ? ' crash' : ' crashes'));
$('.mg-active-datapoint', contentElement).text(d.term + ': ' + d.count + (d.count === 1 ? ' crash' : ' crashes'));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is another area I discovered while fixing the reported issue after I audited other places where we render field values outside of Django/Jinja (which autoescapes).

},
});

Expand Down