Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: escape html #24

Closed
wants to merge 1 commit into from
Closed
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
15 changes: 15 additions & 0 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ var generateHtml = require("./generateHtml");
var exampleKinds = ["coffee", "simple-coffee", "typescript", "babel"];
var SOURCE_MAPPING_URL_REG_EXP = /\/\/[@#]\s*sourceMappingURL\s*=\s*data:[^\n]*?base64,([^\n]*)/;
var SOURCE_MAPPING_URL_REG_EXP2 = /\/\*\s*[@#]\s*sourceMappingURL\s*=\s*data:[^\n]*?base64,([^\n]*)\s*\*\//;
var htmlEscapes = {
'&': '&',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#x27;',
'/': '&#x2F;'
};
var htmlEscaper = /[&<>"'\/]/g;

$(function() {
require("bootstrap");
Expand Down Expand Up @@ -288,6 +297,12 @@ $(function() {
exampleMap.file = exampleMap.file || "example.js";
var map = new SourceMap.SourceMapConsumer(exampleMap);

sources = sources.map(function (it) {
return it.replace(htmlEscaper, function(match) {
return htmlEscapes[match];
});
});

visu.html(generateHtml(map, exampleJs, sources));


Expand Down