Sanitize content of "source with lines" box of sample web app.

This commit is contained in:
David Anson 2016-02-12 22:30:33 -08:00
parent 0832793497
commit 89a7013fc2

View file

@ -26,6 +26,10 @@
var padding = lines.length.toString().replace(/\d/g, " "); var padding = lines.length.toString().replace(/\d/g, " ");
numbered.innerHTML = lines numbered.innerHTML = lines
.map(function mapNumberedLine(line, index) { .map(function mapNumberedLine(line, index) {
line = line
.replace(/&/g, "&")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;");
index++; index++;
var paddedIndex = (padding + index).slice(-padding.length); var paddedIndex = (padding + index).slice(-padding.length);
return "<span id='l" + index + "'><em>" + paddedIndex + "</em>: " + return "<span id='l" + index + "'><em>" + paddedIndex + "</em>: " +